Advertisement

include headers

Started by August 31, 2002 02:20 AM
12 comments, last by ShadowMaster 22 years, 5 months ago
My appoligies for asking a "Newbie" question but, I think this is very important.. What is the logic behind the order of compiling files? I''ve got certain files which I need to be compiled before others..ummm an example: //in main.h #include "utils.h" #include "win32.h" When compiling my project it will go thru my win32.h and say stuff defined in utils.h could were not defined.. No matter how hard I try I can''t understand the way it selects the order to compile all the different files.. Thanks :D -Shadow http://nap.mega.net.kg
Home: EvilEntities ;)
Anything called in win32.h needs to be known about at the time of compilation. So if abc() is called in win32.h and is defined in utils.h, utils.h needs to be compiled first. Kinda like a timeline ... hope this helps.

Luigi Pino
The 23rd Dimension
Advertisement
I don''t have time to write an essay about headers etc, but want to point out that you shall never define any function in a header file. You may declare them there, but no real code should never be placed in a header file (or any other file that you #include), only in .c/.cpp files that will be compiled.
Thanks alot guys, but this did not realy help, I knew this already.. There must be some little mistake I made some where which is causing chaos.. But thanks all the same ...

-Shadow


http://nap.mega.net.kg

Home: EvilEntities ;)
Have you tried including utils.h in main.cpp?
quote:
Have you tried including utils.h in main.cpp?

Yip..
I have tried this..no change..

Here's the Problem: When I compile the output is this:

Compiling...
Utils.cpp
Building: Utils.h
Building: glMain.h
Building: glLog.h
Building: glUtils.h
Building: Win32.h
Building: glPipe.h
d:\projects\c++\diablo\diablogl\glpipe.h(43) : error C2061:
syntax error : identifier 'RGBA'


But 'RGBA' is defined in Utils.h so I'm now confused!

-Shadow


http://nap.mega.net.kg



[edited by - shadowmaster on September 1, 2002 9:57:14 AM]
Home: EvilEntities ;)
Advertisement
What compiler do you use? And it would be helpful if you would outline what is in those files, and how your workspace is put together.
I'm using Visual C++.
I've Sorted the problem not the way, I would have liked to, by moving bits of code from glMain.h and glUtils.h to the glPipe.h file...problem is my code is now no longer orginized and I still don't understand why I'm got that error ...

Here's whats in the files...
Utils.h
Maths Functions like Sine/Cosine look up and other little funcions
glMain.h
Hold all the Macros and Definitions used by all files
glLog.h
Make a debug log
glUtils.h
Tools for OpenGL, eg Screen shot function
Win32.h
Windows Functions eg Make Window / Resize
glPipe.h
Handles Redering, Initilizing etc of OpenGL

Thanks
-Shadow



http://nap.mega.net.kg



[edited by - shadowmaster on September 1, 2002 12:41:22 AM]
Home: EvilEntities ;)
What are you doing!!! You put code in header files?!?! and then include them into other files! Never, ever, do that! You shall put only declarations, typedefs, structs, #defines, etc. in header files, no code whatsoever! The code goes into the .cpp files, which you shall compile build. Into those you include your header files. Man, if you''re doing what I think your doing, you need to get back to the books and read some basics of organizing C/C++ code.

Sorry for the harsch words, no pun intended
wow...No code, sorry! When I say Holds the SayHello Funcion I mean it is ummm Declared(?) there... no actual code.. (?)
umm? am I still doing something stupid?


http://nap.mega.net.kg



[edited by - shadowmaster on September 2, 2002 11:32:57 AM]
Home: EvilEntities ;)

This topic is closed to new replies.

Advertisement