Ah, but you #include <string>, which is a C++ standard header. Perhaps you wanted to #include <string.h> instead.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Oh right, I saw it in the error output.
Anyway, you are using C, yet you are using C++ stuff like std::string.
Seriously, that code needs to rego a big change and either you need to learn C or stick to learning C++, because this code cannot compile as C (namespaces aren't supported in C either).
First thing I turn off in new projects, usually in the wizard, or first thing if the wizard wont let me (win32 projects). The savings even on large projects are negligiable. I have one project that has 100,000 lines of code in ~100 files, each including ~5 headers. It takes about 2 minutes to compile with PCH and 2 minutes 30 seconds without. I dont honestly see the point. I suppose if you had millions of lines of code and tens of thousands of #include's it migth make a bigger difference, but again, whats the point, you will still be compiling for an hour.
IMO they woudl get better performance by multithreading the compile. FileA can be compiled in parallel with FILEB, the linker stage would probably still need to be serial, but not compilation.
Last edited by abachler; 05-15-2008 at 09:17 AM.
Visual Studio is terribly slow with large projects but is reported to be faster than most other compilers. Pre-compiled headers are far more headache than they are worth which is why at home I don't use them and we also do not use them at work.
I've noticed that even on a quad-core machine VS2003 and VS2005 take one core up to 100% and leave the other three at 0%. The compile is multithreaded insofar as you can still interact with the GUI but I seriously doubt if the compile process itself is multi-threaded. It 'appears' to be one thread.
Honestly, i think the whole multithreading thing kind of caught most companies by surprise, it was never a serious technique until multi-core made it give huge performance increases. Now I see hundreds of black box 'turn yoru serial code into parallel code without having to think' solutions. OpenMP, RapidMind, CUDA, although the last 2 are really for use with GPU's its only a matter of time before CPU's support native vector processing. I wouldn't mind, but I end up having to evaluate every new flavor of the month and then explain to the suit why it wont improve our applications or reduce development time (it mostly has to do with some internally closed source libraries that he wont let me get the code to so I can't optimize them).
The only real reason I can see to use PCH is to obfuscate a distributed LIB so thay cant even see your class structure.
Last edited by abachler; 05-15-2008 at 04:47 PM.
I think somewhere both of you have had bad experiences, because I really don't get what you do.
PCH speeds up compiles greatly. You just have to include windows.h and you'll notice how fast it gets. 30 seconds is a big deal if you ask me.
PCH are not difficult to use and they are not error prone (at least not to me). I haven't received any problems with them pretty much in any project I have. Just don't include headers that keep on changing. Only static non-changing headers go there and you should have no problems whatsoever.
So far as I know, VS can only do multi-threaded compile with different projects, because I really have been unable to get it compiling on anything else than one core in one project.
Yeah I know it only uses a single thread, I was just saying they would get better performance increases by going MT than by saddling us with PCH. 30 seconds on a 2 minute compile is nothing, since Im going to get a water and bull........ with a collegue anyway.
In this case your not slacking, your code is compiling. Just like the shirt says....since Im going to get a water and bull........ with a collegue anyway.
I need one of those shirts. My boss is always acting like he is catching me slacking when Im just thinking He got ........ed today because he thought he 'caught' me again when I was just posting the post up above. He thinks im always doing something nefarious, poor guy has a lot of mental issues because of previous employees. I tolerate it because I can empathize with him about getting screwed over, but its getting to the point where he is the one screwing me over by not giving me my reviews or raises or profit sharing. I really would like to get a good review, but if I'm just going to get a crap review then I think its better to cut my losses now and stop wasting time at this company. Its not like he is developing my skill set like I expected. He acts like he has this amazing breakthrough AI that is so secret noone can see the source code, when in reality its just a neural network class that doesnt do anything any other neural network class doesnt do. Even if he did have some amazing new neuron model, it woudlnt matter because you cant get down to the individual neuron, you are saddled with ancient auto associative and hetero architectures. I mean its really frustrating on a personal, intellectual and professional level. He isnt teaching me anything about AI that I didn't already know 10 years ago, he doesnt let me talk to the customers directly, so I'm not making business contacts, and he basically ignores any suggestions I make, in fact he will do the opposite just to spite me. e.g. yesterday another engineer was having a problem with a robot where the set screws on teh wheels keep backign out. SO I suggested using a dab of nail polish to keep the screw from backing out rather than using lok-tite which would keep it from EVER backing out even if you wanted to change the tires (these are really small screws, so you cant get any torque on them to break the lok-tite). He overrides my suggestion and tells the guy to use superglue. I just walked back to my office, how the hell do you argue with a level of intelligence like that?
Last edited by abachler; 05-15-2008 at 09:25 PM.
Ok, took me a while but managed to convert all the code to pure C... I now can compile but down to two warnings... This has to do with the ID of the child window
What you see above is a C++ style, converting into C ...Code:HWND CreateButton(const HWND hParent,const HINSTANCE hInst,DWORD dwStyle, const RECT& rc,const int id,const ustring& caption) { dwStyle|=WS_CHILD|WS_VISIBLE; return CreateWindowEx(0, _T("button"), caption.c_str(), dwStyle, rc.left, rc.top, rc.right, rc.bottom, hParent, reinterpret_cast<HMENU>(static_cast<INT_PTR>(id)), hInst, 0); }
... gives a warningCode:(HMENU)id
Ignoring this warning disables the minimize/restore/close buttons on the window... Any ideas on how to convert this properly?Code:warning C4312: 'type cast' : conversion from 'int' to 'HMENU' of greater size