Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ShadowMaster

include headers

This topic is 5864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!