|
Mustach posted:You shouldn't have to do anything special for the iostream header to be found. Which specific project type did you select? Some of the options create projects targeting .NET's C++/CLI instead of native C++, but I'm not sure that they require anything special, either. It looks like the problem was I as allowing VS 2010 to use pre-compiled headers. There is a checkbox for pre-compiled headers that can be unchecked during the project creation wizard for Win32 console applications....
|
# ? Oct 18, 2010 18:10 |
|
|
# ? Jun 6, 2024 18:01 |
|
Electronic Arts released a bunch of code in the past week over at http://gpl.ea.com, including modifications they've made to Webkit. More interestingly though is that EASTL has been released as part of this package, which someone has already extracted and put up on Github: http://github.com/paulhodge/EASTL
|
# ? Oct 18, 2010 18:19 |
|
pliable posted:1. No no, I've known this for years. C was the first language I've ever learned. I'm just coming back to it now after a long rear end hiatus. The compiler will automatically allocate space for the string literal, but you have no guarantee that that space will be writeable; most compilers will place it in the read-only initialized data segment, or local equivalent. You should consider string literals to be immutable. quote:3. I'll re-read those. Maybe something isn't just clicking when working with them, and they're a lot easier than I think they are. No, string manipulation in C is pretty much unpleasant full stop. That said, c++.com has a nice index of <string.h> functions, which you may find useful. quote:Vino: Knew about that stuff, one thing I was looking for was an easy way to manage them. Looks like I'm going to have to tap into my ASM knowledge and re-learn how to manually manage memory again! And yeah, I have to work with the ANSI standard C library. Can't use any other fancy libraries out there . Where does asm come into this? If you have access to all of ANSI C, you have malloc/calloc/realloc to allocate memory and realloc/free to release it - these are all in <stdlib.h>.
|
# ? Oct 18, 2010 21:24 |
|
pseudorandom name posted:pipe(7) I think I'm in the same class as that guy lol. So far I've been able to get it to do this: code:
edit: My function for the forks looks like this: code:
Acer Pilot fucked around with this message at 15:53 on Oct 19, 2010 |
# ? Oct 19, 2010 15:49 |
|
drcru posted:It doesn't seem to be updating the value of seats_available The "originally" method in the comments is closer to actually updating the value.
|
# ? Oct 19, 2010 16:13 |
|
roomforthetuna posted:Where do you expect it to update that value? It copies it into "seats_open" and then only updates seats_open. I changed it back to how it was originally now but it still only seems to deduct it from seats_available once... Any ideas on what I did wrong?
|
# ? Oct 19, 2010 19:36 |
|
drcru posted:I changed it back to how it was originally now but it still only seems to deduct it from seats_available once... Any ideas on what I did wrong? Though even if it was working as you'd expect, you'd still need some sort of locking anyway, or you risk all 6 processes first reducing the number, then the same reduced number (30) being piped 6 times. Here is someone talking about how to do shared data between forked processes. If you can do it with posix threads, that'd probably be better suited to your task, really, since they share all the memory already so you'd only need to deal with the locking. But seriously, first do the printing information trick to find out what's going wrong with your version, don't just blindly do it someone else's way.
|
# ? Oct 19, 2010 20:38 |
|
roomforthetuna posted:Though even if it was working as you'd expect, you'd still need some sort of locking anyway, or you risk all 6 processes first reducing the number, then the same reduced number (30) being piped 6 times. This is exactly what's happening now, all 6 processes are reducing the number 6 times. Yikes! Thanks, I'll look through the memory locations and that link. I already did it via POSIX threads but our prof also wanted us to try it out with pipes or sockets. The pthreads seemed pretty easy but I'd never worked with pipes before .
|
# ? Oct 19, 2010 20:44 |
|
drcru posted:This is exactly what's happening now, all 6 processes are reducing the number 6 times. Yikes! Pipes are a pain in the arse. However, they once were the only way to do things. One way to do this is to have a process which actually handles the counts for all the rest. The child processes can then ask that processes to decrease its variable and report back the new value. That process could then send a message letting all other processes know what the new value is along with a request and sequence number that the value pertains too. The 6 children can now update any local references (if they care) with the new value. This also works for unix sockets and network sockets. That above design makes a lot more sense once you start thinking distributed systems where things can happen asynchronously.
|
# ? Oct 20, 2010 19:27 |
|
Has anybody here using emacs found a good way to go to the definition of some source code? All I can find online at best is "I don't use such-and-such but I would imagine it has it."
|
# ? Oct 20, 2010 22:40 |
|
Rocko Bonaparte posted:Has anybody here using emacs found a good way to go to the definition of some source code? All I can find online at best is "I don't use such-and-such but I would imagine it has it." http://www.google.com/search?q=emacs+tags
|
# ? Oct 21, 2010 05:07 |
|
I'm trying to debug some C++ code that I didn't write. I found a problem, found where the problem is happening, but I don't know how to fix it. Help me please! Basically, a copy constructor isn't being called, and I believe the implicit copy constructor is being called instead. This is causing problems. The first bit of code is an array wrapper constructor. We get to here just fine: code:
code:
Any ideas?
|
# ? Oct 21, 2010 07:54 |
|
Menacer posted:Basically, a copy constructor isn't being called, and I believe the implicit copy constructor is being called instead. This is causing problems. There's no copying going on here. If you initialize a reference with another reference, it just binds to the original referenced object. So the object referenced by array is the same object referenced by input. Initializing a reference never involves an implicit copy. † † To be precise, you can bind const references (or in MSVC, any reference) to temporaries, and those temporaries can be the result of a user-defined conversion, and maybe that can involve an implicit copy. But not if the source and target types are related at all. rjmccall fucked around with this message at 09:45 on Oct 21, 2010 |
# ? Oct 21, 2010 09:36 |
|
Oh man, now I feel all kinds of Thanks for your help with that!
|
# ? Oct 21, 2010 14:54 |
|
shrughes posted:http://www.google.com/search?q=emacs+tags
|
# ? Oct 21, 2010 16:16 |
|
Don't really know where else to ask, but I'm looking for a very specific way to return a pair of items from a C function. I'm quite aware that I could use a struct, or an array, or just a pointer to some spare memory, but that's not what I'm looking for. A long time ago, I read a blog post or forum post on using some inline assembly and the __naked directive to have some reasonable syntax in C for returning a pair of items. Google isn't turning up anything in the first 10 pages, and the people on StackOverflow are saying the question is too localized. Does anyone remember this or possibly even still have a link lying around somewhere?
|
# ? Oct 21, 2010 19:33 |
|
ReaperUnreal posted:Don't really know where else to ask, but I'm looking for a very specific way to return a pair of items from a C function. You've got some X/Y, buddy
|
# ? Oct 21, 2010 19:48 |
|
Otto Skorzeny posted:You've got some X/Y, buddy No, I'm quite aware that it's a terrible way to return values. I want to see that article again just so I can marvel at that implementation again. It's also what introduced me to calling conventions and the __naked directive. It's also a great reference on how to program like a dick (which is good fun in moderation).
|
# ? Oct 21, 2010 21:38 |
|
(re: X/Y accusation)ReaperUnreal posted:No, I'm quite aware that it's a terrible way to return values... Pet peeve of mine, besides the fact that programmers are socially deaf (Otto's cool tho as are most people here). Every single time I ask a programming question I get somebody giving me Y' for X when I really want Y. I am a flipping good programmer, I understand the X/Y problem. If I wanted to ask about just X I would ask for any solution to X. Usually I'm asking in the first place because X is an easy problem to solve, I already know how to do X, and I need Y for a specific reason (maybe just curiosity). A lot of question answerers have the dang Y' problem. functional fucked around with this message at 23:54 on Oct 21, 2010 |
# ? Oct 21, 2010 23:52 |
|
Anyway, I also want to know the answer to ReaperUnreals question, because it's interesting, even though I would just use a pointer.
|
# ? Oct 21, 2010 23:55 |
|
More of a Sun Studio specific question, I suppose, but you're the best hope I got. What sort of things could cause a program to leak memory (badly) when compiled optimized (in the case of Sun Studio, -xO3) but to leak nothing at all when compiled in debug (-g)? I've run Rational PUrify against the thing in both optimized and unoptimized form, but it can't find a thing, and visual scanning of code is proving fruitless, so I don't even know where to start here.
|
# ? Oct 22, 2010 00:48 |
|
Are you sure it is actually leaking memory, and not holding on to memory for other reasons? IIRC, libumem (their high-performance malloc) uses huge amounts of address space.
|
# ? Oct 22, 2010 01:24 |
|
pseudorandom name posted:Are you sure it is actually leaking memory, and not holding on to memory for other reasons? I can't see how it isn't a leak, especially considering it'll get up to 12GB used in an hour while optimized but stay at around 100-120MB in debug (I just watched this happen). I can sort of watch the leak happen if I compile optimized with debug symbols (-g -xO3), and know what piece of the code I can step across to cause a small leak, but the debugger is unreliable for single stepping, so it doesn't help me much. (Hadn't thought of umem though. We're not using it, but I could try preloading umem as a flailing-in-the-dark-will-this-work option. I guess.)
|
# ? Oct 22, 2010 02:17 |
|
functional posted:(re: X/Y accusation) Updating my thread to ask about my thought process on a memory problem I am having. I am getting nailed with double frees on some stuff, and here I thought I'd be okay with smart pointers! What I think is going on is something like this: 1. Constructor stores a pointer in a smart pointer to a very specific type of object, say class X which inherits from class W. 2. Constructor then stores pointer in a smart pointer that is use a more generic type of an object, say class W. 3. Destructor gets called and smart pointer of for object X gets blown away. 4. The more generic smart pointer then tries to similarly free object X. I am assuming since technically the smart pointers where referring to two different types, they assumed them to be unique. Is there a good way to reestablish this relationship with Boost's smart pointers? Rocko Bonaparte fucked around with this message at 07:26 on Oct 22, 2010 |
# ? Oct 22, 2010 06:06 |
|
functional posted:A lot of question answerers have the dang Y' problem. Probably because a lot of question askers have the X/Y problem. Answering with Y' means you'll be right a lot more often than you are wrong. I see this a lot where people are new to a language/system/library/etc and haven't bothered to learn much about it, so they run into a problem, think of how they would solve it in some other context they're comfortable with, formulate a (deeply flawed) solution based on that, and then ask for help implementing the solution without ever mentioning the problem they're trying to solve unless you drag it out of them: Hey, what would be the best way to keep track of the number of references to an object? Well, that depends on what sorts of object and why you need to keep track of the references. ...twenty minutes of increasingly frustrating discussion ensue... But I need reference counting to know when the object is about to be garbage collected, so that I can clean it up! Just register a finalizer for the object and the language will call it automatically just before it's collected. Oh, you can do that? Why didn't you say so in the first place, now I've wasted all this time!
|
# ? Oct 22, 2010 08:35 |
|
Rocko Bonaparte posted:Updating my thread to ask about my thought process on a memory problem I am having. I am getting nailed with double frees on some stuff, and here I thought I'd be okay with smart pointers! What I think is going on is something like this: code:
code:
|
# ? Oct 22, 2010 12:02 |
|
Dumb linking question in C++. Say I have a static (or dynamic) library compiled with C++ compiler X. Now say I have a main program that wants to link that library, except its object files are being compiled with C++ compiler Y. Is doing this link generally possible? If not, what can I do short of recompiling the main program with compiler X (or getting the vendor to recompile my libraries with compiler Y, but hahhaha ) (In this specific case, X is Sun CC 12.1 and Y is GNU G++ 3.4.2 all on a solaris box of... some kind I honestly can't remember. But I'd rather know in the more general sense if there's a more general answer. ) Ciaphas fucked around with this message at 04:29 on Oct 23, 2010 |
# ? Oct 23, 2010 04:11 |
|
GCC and SunCC don't use the same C++ ABI, so, no, that won't be possible.
|
# ? Oct 23, 2010 04:36 |
|
drat and five thousand blasts. I hate sun CC so much it is so phenomenally buggy (Far be it from me to look stupider in here, but... ABI?)
|
# ? Oct 23, 2010 04:38 |
|
Frequently impossible. More specifically, it depends on whether they use the same C++ ABI (Application Binary Interface --- which specifies how function names are encoded and layout of things like objects and vtables). For a long time basically everyone's scheme was different --- even different gcc versions were incompatible. There are perhaps a few more compatibilities now: both g++ >= 3.2 and some other Unix-friendly compilers like Intel's use the same ABI that was cooperatively designed for Itanium, but there is still a lot more that's different than that's same. (Also, I am not 100% sure of how the runtime library stuff is supposed to work when mixing compilers...) It -seems- that Sun CC is incompatible, but luckily the difference appears to be huge --- you'll likely just get tons of link errors if you try. Edit: if you want to know more about how an ABI looks, here is what g++ uses: http://www.codesourcery.com/public/cxx-abi/abi.html There is also of course an ABI for C that this builds on. Those are usually pretty much compatible since they're much simpler, but sometimes problems still crop in with stuff like SSE and whatnot. OddObserver fucked around with this message at 04:50 on Oct 23, 2010 |
# ? Oct 23, 2010 04:47 |
|
Yeah, while I was at work I was trying to do this link--it kept throwing up undefined symbols even though I KNOW I got all the link arguments in the right order. That's when I realized I should ask the question I asked here. I guess if the two compilers don't even name-mangle the same, well, that'd explain that. Thanks folks
|
# ? Oct 23, 2010 05:06 |
|
SunCC and GCC may not agree on the C++ ABI, but they should still agree on the C ABI, which you can embed within C++ using extern "C" declarations. So it's still possible to make the libraries interoperate if you can stand to go through a C interface. Of course, that means each library has to treat pointers from the other as totally opaque, but that might be workable.
|
# ? Oct 23, 2010 07:01 |
|
How the gently caress do you read in binary data as a character? I'm not sure how to fully explain this, but I'm writing a huffman encoding program. I can be given binary or character data. My program works fine with character data, but when it comes to binary, it fails to render correct encoding. I'm reading in my data like this:code:
ToxicFrog posted:No, string manipulation in C is pretty much unpleasant full stop. Bookmarked, thank you
|
# ? Oct 23, 2010 08:51 |
|
pliable posted:How the gently caress do you read in binary data as a character? Is the buffer array defined as unsigned char?
|
# ? Oct 23, 2010 15:17 |
|
Mustach posted:
|
# ? Oct 23, 2010 17:08 |
|
ehnus posted:Electronic Arts released a bunch of code in the past week over at http://gpl.ea.com, including modifications they've made to Webkit. Oooooooooooooooo Has anyone tried getting a fairly performance intensive project and comparing performance of EASTL vs std STL?
|
# ? Oct 23, 2010 18:28 |
|
MutantBlue posted:Is the buffer array defined as unsigned char? This fixed my problem...thank you very much!
|
# ? Oct 23, 2010 23:07 |
|
pliable posted:This fixed my problem...thank you very much! Glad to help, you were getting char values in the range -128..127 which are obviously bad indices for your counts[] array. Did you take out the junk that looked like code:
code:
|
# ? Oct 24, 2010 00:26 |
|
This leak that's only appearing when I compile optimized and doesn't show up in Purify has me at my wit's end. Does anyone have any ideas on how I might be able to track the total memory usage of particular objects, or even all objects of a given class? I get the feeling sizeof() wouldn't be the right answer here, but I'm basically flailing in the loving dark now. (edit) I've tried overloading global new and delete, with #defines to let me get __FILE__ and __LINE__, but one of the libraries I have to use reeeally dislikes that (stupid placement new...). (edit) I have a sudden suspicion that it might be an uninitialized member variable that's doing it. Debug compiles typically set those to 0 or blank string or whatever on declaration, whereas if you don't initialize them a release compile typically does jack and/or poo poo, right? Is there any non-compiler-specific way to check if any variable initializations are being forgotten? (edit again) Oh, sorry, I forgot. I'm on Solaris, using Sun CC 12.1. So no Valgrind (edit a third time) Man I wish I could use a linux livecd or had a linux box, solaris makes me so cross Ciaphas fucked around with this message at 04:24 on Oct 24, 2010 |
# ? Oct 24, 2010 04:06 |
|
|
# ? Jun 6, 2024 18:01 |
|
If you're on Linux or OS X use valgrind's Massif tool. Edit: and for non-initialized variables, its default Memcheck tool. It's also generally not true that debug builds do any special initialization (though some debug version of malloc fill fresh memory with known patterns). Edit #2: It might honestly be worth the effort to try building it under Linux to just run Valgrind. There is some chance it wouldn't be much work, and if you don't have a Linux system it's easy enough to just use a LiveCD. OddObserver fucked around with this message at 04:12 on Oct 24, 2010 |
# ? Oct 24, 2010 04:09 |