Needed help with spliting up code

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Needed help with spliting up code

Post by MarauderIIC »

Possibly because "extern blah" and "blah" are in the 'same file', since you #include "globals.h" in globals.cpp (this sort of pastes globals.h into globals.cpp). Ummm... try separating your externs out into a different .h or just writing the specific ones in the .cpps where they're needed? Not sure, extern's not something I've used since I was modding Q2.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Norbo
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Mar 19, 2009 11:58 am

Re: Needed help with spliting up code

Post by Norbo »

I tried a little test to see if i have my globals somewere in my code
i didint include globals.h in any of my files, and i didint have multiple definition probloms
instead, i had the compiler complaining about the globals undeclared.
when i included globals.h back again, i have multiple definition problems.
User avatar
PixelP
Chaos Rift Regular
Chaos Rift Regular
Posts: 153
Joined: Tue Oct 07, 2008 12:23 pm
Programming Language of Choice: c/c++
Location: sweden
Contact:

Re: Needed help with spliting up code

Post by PixelP »

MarauderIIC wrote:
PixelP wrote:you must do "extern" before every function in the header file.
False. I've never seen it done this way and assume bad practice.
oh, i didnt know that. sorry for giving out false information.
Norbo
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 15
Joined: Thu Mar 19, 2009 11:58 am

Re: Needed help with spliting up code

Post by Norbo »

problem solved.
i had to rebuild by priject because dev c++ was going crazy
im moving on to c::b
User avatar
kostiak2
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 74
Joined: Tue Mar 24, 2009 4:08 pm

Re: Needed help with spliting up code

Post by kostiak2 »

Norbo wrote:problem solved.
i had to rebuild by priject because dev c++ was going crazy
im moving on to c::b
I would recommend going for Microsoft Visual C++ Express actually, It's as free as the other two, but it is more powerful in 2 things - a great auto complete system (great for lazy coders ;) ) and even better: a very good debugger (great for non-perfect people ;) )
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Needed help with spliting up code

Post by MarauderIIC »

Con: Hard to distribute finished product. Nobody with a distribution problem has solved it yet. I think there's a thread in this forum about it.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
kostiak2
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 74
Joined: Tue Mar 24, 2009 4:08 pm

Re: Needed help with spliting up code

Post by kostiak2 »

MarauderIIC wrote:Con: Hard to distribute finished product. Nobody with a distribution problem has solved it yet. I think there's a thread in this forum about it.
Actualy no, you can redistribute easily with it, I do, and I helped the guy who was having trouble with it.

(Basically it all comes down to changing a single project setting and adding 2 dlls of about 0.7mb each.. not such a big deal..)

No Con XD
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: Needed help with spliting up code

Post by qpHalcy0n »

This has actually been a pretty big problem with VS9 in particular (VS2008 series). It's been a problem with all MS compilers, however; its a horrendous problem with 2008. If you ever run across code that you absolutely know should work or that a change was made then undone, especially where it pertains to multiple definition or NO definition: try a complete rebuild and 8 out of 10 it'll work.

The issue is that VS does not always correlate changes in source to changes across object files, so it does not recompile them though it may need to. Rebuilding destroys all the intermediates and object files, so the build time would be longer, but complete. It's always a good idea before a major build to rebuild the entire project under release and debug builds both with and without compiler code optimization before revisioning.
Post Reply