Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / C++ Include File Problems

Author
Message
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 20th Feb 2008 23:18
Does anyone else run into strange errors when trying to make modular C++ files - and include them in a way that they can all reference each other. I think a C++ (VS2008) style Circular reference just says "YouObject Not Defined" when I know for a fact it is DEFINED.

I the Past - I had basically ONE HUGE source file - and believe it or not - besides making the text editor go slow as heck - it compiled wonderfully. A bit cumbersome.

this go around - I made separate files for each functional compoenet - and they DO reference each other - but every so often I run into some dumb error during the compiler that I KNOW is because soemhow - the order of the files isn't right in how they get loaded during compile - YES I use the #pragma once directive.

Does anyone else have issues like these?

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 21st Feb 2008 01:06 Edited at: 21st Feb 2008 01:08
I had the same problem but, If you include all the necessary files say in you main source file. Then, just prototype the functions in the respective files before the calling function.

For instance:

main.cpp



myfunc.h



callingfunc.h



In this case you could just change the include order in main.cpp, but to demonstrate what I mean I added them in a way which would cause a build error without the prototype.

Projects Started: 20
Projects Completed: 0
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 21st Feb 2008 01:42
Thanx for stopping in Monotonic!

I do understand the concept - I mean - I'm the one asking for help and you responded and I AM grateful. Unfortunately - like you well know - the more you know the harder it is to ask for help - not because you don't want to - but because trying to ask the question to the kinds of stuff that stumps an advanced programmer is not easy - and the expected reply - "Show the source" means uploading a couple megs of source code! LOL

Yeah - I solved the problem - but I don't know why/how exactly - par for the course with Microsoft I guess.

First out of frustration - I INCLUDED EVERY SINGLE file for the whole project (even though the necessary includes were already there (as compiler was complaining of lack of a semi colon - which was there - it was choking on a CLASS I was trying to inherit - and that class's file was included where it needed to be) any way - I included EVERYTHING (included everything in project) into this file and the matching CPP file - then I Totally Rebuilt the whole solution and it work.

It truly doesn't make sense - unless 1: the massive includes I did caused the compiler to compile stuff in a different order and the weirdness didn't apply - or rebuilding the solution from scratch (which I did before no success) did it or something. Dunno - I HATE when I don't know why.

I've screwed up projects because I had a one where a two should of been and converted thousands of database records incorrectly due to such simplton err but at LEAST I know what I did wrong - and fixed - (which sucked in this particular case) - but its WORSE not knowing WHY it works now.

One time in DBPRo - something (shoot ..Iron Infantry first Draft) thousands of lines of code all of a sudden wouldn't run right! directx was screwy - locking up WHAT THE!!! posted whined cryed - then I shut the system down - went to bed mad. When I woke up - I booted up - it worked. (Reboot needed cuz was baning on DirectX to much? Dunno - but I'll buy that as - computer hosed... this C++ include thing is BAFFLING.

FYI - I have over 64 files (*.h and *.cpp) in my project - so the basic rules to include files, headers, and source CPP I got - thias thing was just not playing by the rules...I don't think - ...ugh....I hate not knowing.

Thanx for popping in though - seriously. you always have really cool posts!

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 23rd Feb 2008 17:25
I wanted to say I ran into this linking issue again after adding yet another file pair (header and source) to my project and I wanted to post how I most recently seemed to have squashed the problem.

Laborous? Yes - but it cleaned out a bunch of unnecessary things I was including - and has made things go alot smoother.

If your project complains of things like
or
but you KNOW you included the right files for sure?

Comment out EVERY include file statement in your entire project!

Then compile - See Error? Cntl Break. Add the necessary include to make the First Error Go Awway - THAT's IT! don't Assume you know what the compiler wants for the whole file (this is where I think I screwed things up). Repeat! One at a time!

simple? Yeah. Iterative? Yeah. Worth it? I think so! I found I was including WAY to many files redundantly - and even with the "#pragma once" thing in each header file - I was hosing things.

So - that's my finding. Cure for Circular references? I'm not positive - but so far - I'm having a better time of it.

Login to post a reply

Server time is: 2024-09-29 13:36:02
Your offset time is: 2024-09-29 13:36:02