|
shodanjr_gr posted:What the heck am I doing wrong? The rest of the code compiles just fine Depends on how you were trying to compile it before (as in, what command line did you use, including any other source files?).
|
# ? Dec 27, 2008 04:57 |
|
|
# ? May 12, 2024 15:11 |
|
I'm using g++ on linux and I have Boost installed in $HOME/local64 (libs are in ./libs and includes are in ./include/boost). When I compile I need to add -L $(HOME)/local64/lib to the linker flags in order for it to compile (else I get the error: code:
Any ideas? Bitruder fucked around with this message at 19:12 on Dec 27, 2008 |
# ? Dec 27, 2008 19:02 |
|
Bitruder posted:I'm using g++ on linux and I have Boost installed in $HOME/local64 (libs are in ./libs and includes are in ./include/boost). I would suggest making yourself a Makefile. Stick all the non-standard paths you need to search in there and then forget about it. This also has the nice side effect of documenting your strange dependencies.
|
# ? Dec 27, 2008 21:09 |
|
Nippashish posted:I would suggest making yourself a Makefile. Stick all the non-standard paths you need to search in there and then forget about it. This also has the nice side effect of documenting your strange dependencies. Yes, I use a Makefile. The thing though, is that I want to distribute my source, so the -L flag would be specific to my computer instead of being more general.
|
# ? Dec 28, 2008 00:40 |
|
Bitruder posted:Yes, I use a Makefile. The thing though, is that I want to distribute my source, so the -L flag would be specific to my computer instead of being more general. If you create a configure script with autoconf, you have the ability to pass the script a prefix for your libraries and such, so that could be a good solution. And it's definitely not a bad idea to include a configure script if you're planning on distributing your source, because other people might have weird paths too.
|
# ? Dec 28, 2008 01:16 |
|
Bitruder posted:I'm using g++ on linux and I have Boost installed in $HOME/local64 (libs are in ./libs and includes are in ./include/boost). If you haven't blown away the implicit rules in your makefile, set CXXFLAGS/LDFLAGS in your environment or pass it on the command-line to make.
|
# ? Dec 28, 2008 19:51 |
|
I'm a programmer with a fairly decent command of C, and enough Java and Python that I'm familiar with general OOP techniques as well. Is there a good book that introduces C++, while not going over the basics of C at the same time (or, even better, one that specifically highlights the differences between the two)?
|
# ? Dec 28, 2008 22:21 |
|
Is stringstream only supposed to be used for numerical values? I'm trying to do a single line of input for 2 strings and 2 integers, by doing something like:code:
code:
Cosmopolitan fucked around with this message at 00:25 on Dec 29, 2008 |
# ? Dec 29, 2008 00:21 |
|
I'm too lazy to verify this, but I think you need to make that stringstream a named variablecode:
|
# ? Dec 29, 2008 00:51 |
|
I'm pretty sure temporaries are non-const but can't be bound to non-const references due to the fact that it's an r-value.
|
# ? Dec 29, 2008 01:06 |
|
Mustach posted:I'm too lazy to verify this, but I think you need to make that stringstream a named variable Hmm, this compiles with no errors, but it's not extracting any values from the input.
|
# ? Dec 29, 2008 01:08 |
|
Then you're doing it wrong.
|
# ? Dec 29, 2008 01:32 |
|
Avenging Dentist posted:Then you're doing it wrong. Oh, okay, just realized I didn't do a cin.ignore for a cin that happens before my getline. It's working now. Thanks a bunch. On that note, if someone is willing, I'd like to better understand in what circumstances you'd need to use cin.ignore, and for what reason. This way, I will just know when to use it, rather than using it as a quick fix for when the input gets funky.
|
# ? Dec 29, 2008 01:53 |
|
Formatted input doesn't read delimiters after the input (e.g. newlines) so you have to pop off the newline if you want to use getline.
|
# ? Dec 29, 2008 02:05 |
|
How the poo poo do I allocate memory for a struct array like this with HeapAlloc?code:
|
# ? Dec 29, 2008 11:30 |
|
slovach posted:How the poo poo do I allocate memory for a struct array like this with HeapAlloc? If you really want to use HeapAlloc for some reason: code:
code:
code:
|
# ? Dec 29, 2008 15:46 |
|
Is there a quick and reliable way to check if X11 is available? My application is (Linux of course) a CLI application that generates EPS images. If X11 is available, I'd like to launch gv image.eps to show the user, but if it's not available, I won't bother. This isn't a compile check since users could be running this off their desktop or maybe just SSH'ing in.
|
# ? Dec 29, 2008 21:34 |
|
Bitruder posted:Is there a quick and reliable way to check if X11 is available? My application is (Linux of course) a CLI application that generates EPS images. If X11 is available, I'd like to launch gv image.eps to show the user, but if it's not available, I won't bother. This isn't a compile check since users could be running this off their desktop or maybe just SSH'ing in. The standard technique is to check whether the DISPLAY environment variable is set, though I would suggest also adding a command-line option to enable/disable/configure this feature. rjmccall fucked around with this message at 21:54 on Dec 29, 2008 |
# ? Dec 29, 2008 21:52 |
|
prolecat posted:Also, I believe if you're just using C and not C++, the casts in the first two examples can be removed, prolecat posted:and you'll also have to use "struct Star * stars" and "sizeof(struct Star)" instead of just Star. code:
code:
|
# ? Dec 29, 2008 23:30 |
|
I have a question about the lifetime of stack objects that are r-values in C++. Say I do something like the following:code:
Mr.Radar fucked around with this message at 02:42 on Dec 30, 2008 |
# ? Dec 30, 2008 02:35 |
|
12.2.3. Temporary objects are destroyed as the last step in evaluating the full-expression that lexically contains the point where they were created. The two exceptions are when initializing reference (12.2.5) and non-reference (12.2.4) variables, both of which only extend the lifetime of the object. So gcc's behavior is, in fact, mandated by the standard.
|
# ? Dec 30, 2008 07:19 |
|
Thanks! That makes things a lot easier for me.
|
# ? Dec 30, 2008 16:44 |
|
Got a simple one for you C++ goons: How can I create a two-dimmensional array of pointers to objects of class Foo?
|
# ? Dec 30, 2008 22:38 |
|
shodanjr_gr posted:Got a simple one for you C++ goons: http://www.boost.org/doc/libs/1_37_0/libs/multi_array/doc/user.html#sec_introduction
|
# ? Dec 30, 2008 22:53 |
|
Thanks for the reply. I am trying to avoid using another library if possible (plus I want to refresh my C++ skills particularly with regard to pointers and stuff). Actually, I think i figured it out and it goes something like this: code:
|
# ? Dec 30, 2008 23:45 |
|
That's not a two dimensional array to Foo-pointers, that's a pointer-to-array of pointers-to-arrays of Foo-pointers.
|
# ? Dec 31, 2008 00:03 |
|
Avenging Dentist posted:That's not a two dimensional array to Foo-pointers, that's a pointer-to-array of pointers-to-arrays of Foo-pointers. Is there a large functional difference between the two?
|
# ? Dec 31, 2008 00:27 |
|
2d arrays are rectangular, arrays of pointers-to-arrays are jagged. Also I am required to tell you that your code is extremely exception-unsafe.
|
# ? Dec 31, 2008 00:40 |
|
Avenging Dentist posted:Also I am required to tell you that your code is extremely exception-unsafe. I got another one. code:
code:
shodanjr_gr fucked around with this message at 01:11 on Dec 31, 2008 |
# ? Dec 31, 2008 01:03 |
|
shodanjr_gr posted:
Hey guys, time for another round of "Guess the problem without the error message"! (My guess: you don't actually define Foo::A_STATIC_MEMBER_OF_FOO anywhere (the code you have just declares it).)
|
# ? Dec 31, 2008 01:06 |
|
You're declaring your static member as const but trying to return a non-const reference to it.
|
# ? Dec 31, 2008 01:30 |
|
You're also trying to put a foo inside a foo, which is not possible.
|
# ? Dec 31, 2008 02:08 |
|
Nippashish posted:You're also trying to put a foo inside a foo, which is not possible. Is your mind blown???
|
# ? Dec 31, 2008 02:42 |
|
Avenging Dentist posted:Is your mind blown??? :O
|
# ? Dec 31, 2008 03:10 |
I'm having a strange problem with std::deques.code:
Before legalizeTriangle, triangles.size() is 3. I step into legalizeTriangle and the size of triangles is 67896278964243840598345 code:
EDIT: For clarity, the size changes AS SOON as I step into the function. It's as if passing the stl container changes the values inside. Jo fucked around with this message at 20:55 on Jan 1, 2009 |
|
# ? Jan 1, 2009 20:53 |
|
Jo posted:What the gently caress are you talking about? Learn how to communicate properly. Edit: Your compiler's broken. Edit: Why don't you isolate the problem in some demonstratory program, so that people can actually tell you what's wrong, rather than saying "Hey, you're right, that looks funny."? shrughes fucked around with this message at 21:29 on Jan 1, 2009 |
# ? Jan 1, 2009 21:04 |
shrughes posted:What the gently caress are you talking about? Learn how to communicate properly. Noted. I thought the GDB excerpt was self explanatory. I'll try to be more clear. Also, working on an isolated test case.
|
|
# ? Jan 1, 2009 21:39 |
|
Don't you want to make LegalizeTriangle take a const reference rather than make a copy?code:
|
# ? Jan 1, 2009 21:59 |
beuges posted:Don't you want to make LegalizeTriangle take a const reference rather than make a copy? Goddamnit. Works now. Thank you.
|
|
# ? Jan 1, 2009 22:42 |
|
|
# ? May 12, 2024 15:11 |
|
It should still work the other way, though. Copying isn't the real problem, it merely somehow exposed the real problem... Maybe you previously smashed your stack (and still are) and making this local copy was the final straw, maybe your compiler is busted, who knows, there just isn't enough information here to guess. Personally, I wouldn't be content that the real problem is fixed at this point.
|
# ? Jan 2, 2009 03:26 |