« first day (526 days earlier)      last day (2333 days later) » 

8:09 AM
Oh I understand it now. I just got a bug thinking that address of an object can change.
I.e. change without older place not being available.
 
 
2 hours later…
10:22 AM
i want to draw a so called orientation aid to support the user to orientate within the scene. its just another draw of an cube, which symbolize the camera orientation, in its own viewport and projectionmatrix. my questions is, would you encapsulate this in a method or just put this, how it is, in the rendering loop?
 
11:03 AM
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_08
There is backreferencing in BREs and grouping in EREs. What's the difference?
Either I am blind or document does not define "grouping" at all.
 
 
4 hours later…
2:38 PM
isthe use of smart pointers correct here?
 
3:30 PM
hello?
 
hello
i have a question
i saw this code on msn website
and as i was reading it i saw this:
it had a function named ErrorExit declared like this:
VOID ErrorExit (LPSTR message) { //do stuff ...}
and in main they called the function with something like this:
ErrorExit("Unknown event type");
my question is why do they put as parameter of ErrorExit a LPSTR object
this is the full function:
 
it's not an object
is a typedef
 
VOID ErrorExit (LPSTR lpszMessage)
{
fprintf(stderr, "%s\n", lpszMessage);

// Restore input mode on exit.

SetConsoleMode(hStdin, fdwSaveOldMode);

ExitProcess(0);
}
 
@user8469759 yes, but why did they put that as a parameter?
wouldnt they be better of with a string or a char[] ?
 
3:34 PM
yeah, but that's simply windows programming style
typedef CHAR *LPSTR;
(by the way)
 
@user8469759 what do you mean?
 
that that's a windows function definition
they typedef their types in that way
 
but why would you use a typedef there?
 
in that case LPSTR is a char array
 
isnt it a pointer to a 8 bit string?
i mean array of chars
not string
 
3:36 PM
again, it's a char array, so it is a C style string
if your question is whether or not there's a benefit of the typedef
that's a "different" thing
 
is there a benifit in using a typedef?
in this case
 
say you have many functions like these
typedef CHAR *LPSTR;

void f1(LPSTR par);
void f2(LPSTR par);
void f3(LPSTR par);
void f4(LPSTR par);
and you want to change the type of par for each function, you would just change the type of the typedef
or maybe you could have something like
 
ohhhhhh
 
#if PLATFORM_1
typedef CHAR *LPSTR;
#else
typedef OTHER_TYPE LPSTR;
#endif
void f1(LPSTR par);
void f2(LPSTR par);
void f3(LPSTR par);
void f4(LPSTR par);
that would be platform independent
 
so having VOID f1(char*[] par) is the same as VOID f1(LPSTR par) ?
 
3:40 PM
VOID ErrorExit (LPSTR lpszMessage) ;
should imply
VOID ErrorExit (char* lpszMessage) ;
as far as the documentation says
 
but why is it char* and not char*[] since it needs a char array
they say it here
 
typedef char* PSTR, *LPSTR;
if I remember correctly
each windows type is a shorthand for something
like PSTR
means Pointer to STRing
not entirely sure what the L stands for
 
i think the L is for Long
 
probably
 
LP stands for "long pointer"
incidentally the main indicator why "hungarian notation" is garbage
 
3:43 PM
so @user8469759 why does it say there that is a pointer to an array of chars, and why do you pass a (char* parm) and not a (char*[] parm) to the function?
i knwo it is defined as char*, but they say in the link that is it a pointer to an array fo chars
so im confused
 
because "long pointers" are from the days of 16 bit x86 architecture
 
not entirely sure you can work it out by the typedef you linked
typedef char* PSTR, *LPSTR; which would imply typedef char* *LPSTR;
 
"The LPSTR type and its alias PSTR specify a pointer to an array of 8-bit characters, which MAY be terminated by a null character."
 
typedef CHAR *LPSTR; this is what I linked
typedef char* PSTR, *LPSTR; this is what you linked
 
what is the diferent?
 
3:47 PM
upper case vs lower case (CHAR vs char)
 
isnt that the same?
or does the size changes?
or what changes?
 
nothing, not sure why windows defined CHAR as char (I'm reading through my link)
 
ah
so if its the same
shouldnt it be defined like this: typedef char*[] *LPSTR;
because they say that its a pointer to a char array
or am i analysing it wrong?
 
one sec, writing some code to test that definition
(your one)
 
ok!
 
3:53 PM
ok according to your typedef
LPSTR is actually a double pointer
mine is defined in WinNT.h
your one is defined elsewhere
so in theory substituting entails the double pointer
 
are you talking about this one? typedef char* PSTR, *LPSTR;
 
yes
I've tested with this
#include <cstring>

typedef char* *LPSTR;

int main(int argc, char **argv) {
	char v[] = "Test clock!";
	LPSTR u;
	strcpy(u,v);
	return 0;
}
if I compile I get this error in particular
cannot convert ‘LPSTR {aka char**}’ to ‘char*’ for argument ‘1’ to ‘char* strcpy(char*, const char*)’
which means actually LPSTR is seen as double pointer (char**)
(never used typedefs like that)
 
try to run with *LPSTR u;
shouldnt that work if you do that?
 
i see
 
3:59 PM
but anyway, using that you actually seem to have
VOID ErrorExit (LPSTR lpszMessage) ;
should imply
VOID ErrorExit (char** lpszMessage) ;
 
so a char pointer to a pointer
weird
 
unless I'm missing something, but it seems to be in that way
 
im going to test something and if it works or not ill post results and code 1 sec
ok
cpp.sh/5gybo
i get 2 errors
first, whydoes the compiler consider "This is a test" as a char *?
 
in your
ErrorExit
what do you include to use that LPSTR
?
 
<windows.h>
 
4:05 PM
it seems to use my definition
 
the LPSTR is a string basicly
 
what IDE are you using? visual studio? eclipse? notepad?
so it's a char*
 
so i dont get it why the printf gives error
emacs
 
well anyway
you can go backward in all your includes
and find what definition of LPSTR you're using
but it seems to be char*
so I'm not entirely sure the line you gave me where it is taken from
 
so using LPSTR should be the same as using char *, but its not aparently
 
4:07 PM
why not?
 
good question, the compiler says is a char **
 
(I would rely on this for the types anyway msdn.microsoft.com/en-us/library/windows/desktop/…)
well my link says typedef CHAR *LPSTR which is typedef char *LPSTR which means LPSTR is char*
the error I provided you it's because of my definition of LPSTR
defined by me
 
im talking about typedef char* *LPSTR
why is that a char**
 
ok, but are you sure that's the one you're using in your code?
 
yes
 
4:09 PM
where is it defined?
 
windows.h
 
in <windows.h>?
 
yes
 
hmmm
wait a sec
trying to find the header
so I can look up the definition of LPSTR
I can't see any LPSTR
 
what include were you using?
winNT.h i think
ah
ok
i see were the problem is
 
4:18 PM
hm?
 
i though that this link was from the windows.h lib
 
which one?
 
windows.h uses the same typedefs as winNT.h
 
does it?
 
this one
yes
it does
at least thats what i understuud from the comments they used
/* translate GCC target defines to MS equivalents. Keep this synchronized
with winnt.h. */
 
4:20 PM
ok
 
that was inside windows.h
 
well then do we agree that LPSTR is char*?
 
well, problem solved
yes, if it is defined like this typedef CHAR *LPSTR
 
thanks!
 
4:22 PM
why are you using windows libraries anyway?
just for the sake of?
or do you actually need it
 
actually need them
im working in windows
 
what for?
If I may ask
 
do you know the program DosBox?
 
is it the DOS emulator?
 
yes
 
4:23 PM
yes
 
im trying to make something similar
in console
 
are you writing your own OS?
or just an interpreter
 
no, just a similar interface
its only to lookpretty
 
from very scratch
couldn't you use QT for the same thing?
 
i dont know, im not familiar with Qt
 
4:25 PM
it's basically a toolkit to program GUI in c++
 
ohhh, no, im making in console
like the prompt
like DosBox
 
don't you want to design a small window where you can type in?
 
you can type in a console
 
I haven't seen msdos in ages
(I'm watching a youtube video)
 
ahahaha, well when you code view a asm exe in dosbox, it puts you in a console that you can move your mouse around and it moves on console, and you can click buttons on a console and all that
i think its cool so im trying to make that
 
4:28 PM
that's actually cool
 
ye, masm 8086 style
 
 
1 hour later…
5:33 PM
@user8469759 Qt provides quite a lot more than just GUI stuff--it's a much more of an all-encompassing framework than just a GUI toolkit.
 
 
5 hours later…
10:22 PM
would anybody be up to help me get Qt working with netbeans?
I've got some odd issues that don't really match up with anything I can find online
 
11:05 PM
Hey
What does "float x[n]" means? Is it making a vector of floats of n size?
 
no
Given a runtime n, this is non-standard C++
Visual C++ won't compile this for example
and neither will g++ if you pass -std=c++XX -Wall -Wextra -pedantic -pedantic-errors
 
@Dariusz Technically, an array, not a vector. Requires that n is const to be standard. But it's generally better to use an actual vector, like std::vector<float> x(n);
 
11:33 PM
humh
interesting
vector<float> e(3);
seems to not be working getting syntax error )
 
did you #include <vector>
 
yup
I'm doing it in header tho
 
it's spelled std::vector BTW
throw using namespace std; to the trash where it belongs
 
trying to define vector3D
humh still erroring
 
SSCCE please
 
11:38 PM
sscce?
 
ohh
before I dig in to making test file maybe this could help. :
https://pastebin.com/LA8mBKAs
when I had float e[3], it worked but when I changed to vector then it all errors out
 
You probably want to use std::array<float, 3> instead
I mean, std::vector<T> is for when you don't know the size till compile time
but you here you know: it's 3
That said, std::vector<float> e(3); is not legal in class scope
You want to move this to member initializer list
icrVec3() :
    e(3)
{
    e[0] = 0.0;
    e[1] = 0.0;
    e[2] = 0.0;
}
 
humh
thats new
so I have to put std::vector<float> e above my icrVec3() constructor
and then add :e(3) to constructor so that he reserved memory for 3 items
 
std::vector<float> e(3); -> std::vector<float> e;
+ the code above
 
11:46 PM
strange I always though that array and vector were thesame
yep
 
(in all constructors)
 
(yep thanks :- ) )
 
that said, you really want to use std::array<float, 3> here instead
 
std::array<float,3> e?
 
yes
std::array<float, 3> e;
 
11:47 PM
yup
 
(you need to #include <array>)
 
I see, I'll read up on arrays
 
@Dariusz std::vector<T>, std::array<T, N> is C++, T[N] is from C (here C is compile-time constant)
you want to avoid the latter in the new code
stackoverflow.com/questions/4810664/how-do-i-use-arrays-in-c <- here's an introduction to C-arrays, if you want to know why you want to avoid them :D
 
I see, I was just reading this > stackoverflow.com/questions/15079057/…
 
If some C function expects a pointer to the first C-array element, you can instead pass vec.data() or arr.data()
 
11:51 PM
so the array seems to be much older and a bit more... "fixed" ie I cant resize it at runtime/etc. Does it mean that because of it its a lot simpler also faster?
o interesting with that tip above thanks!
 
T[N] of hardcoded size is faster than std::vector<T>, but the same can be said of std::array<T, N>
 
hmm black magic, I wonder why the book suggest arrays over vector
 
because it's old and/or bad
std::array<T, N> is >=2011, but that's like 6 years ago
 
for intensive math calcualtion - raytracing/geometry managment, would you suggest vector over array?
 
accessing individual elements is just as fast
creating is slower with vectors
 
11:54 PM
via array?
creating is slower using which option?
I kinda realized I will need miltions of vector3D so I guess every little helps o.o
 
yeah, which is why
12 mins ago, by milleniumbug
You probably want to use std::array<float, 3> instead
 
yap
 
if sizeof(std::array<T, N>) goes over several kilobytes, you want to switch to std::vector<T>, even if you know the size at compile time
(to avoid stack overflows for local variables)
 

« first day (526 days earlier)      last day (2333 days later) »