Archived

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

Jason2Jason

include differences

Recommended Posts

Jason2Jason    166
Hi, I''ve recently switched from using Borland C++ Builder 4 pro to MS Visual C++ 6 standard. I was moving some source files over in a project and i noticed it didnt like the way i included header file. In BCB i included things like gl.h in the main source file, when i included my own source and header file, they would get instant access to the first included file (ie gl.h) without typing #include <..> again in the file. VC++ doesnt like this so i typed out a new #include <gl\gl.h> in one of the source files. It now comes up with errors in the gl.h file! I take it that it has something todo with multiple includes or some thing. Could some one tell me how to get around this problem in VC++? If your confused of what i said, say and i''ll retype this clearer if i can! Thanks -J

Share this post


Link to post
Share on other sites
Promit    13246
It would mainly help if you told us what the errors were(error codes and text) and gave us an example of what you''re trying to do.

____________________________________________________________
Direct3D vs. OpenGL

Share this post


Link to post
Share on other sites
Jason2Jason    166
I''ve had to include:

#include <windows.h>
#include <gl\gl.h>

in most of my project files, so that the functions are reconised. Now it comes with these errors:

c:\windows\desktop\c++ stuff\3d snake\vc\scene_control.cpp(2) : warning C4182: #include nesting level is 362 deep; possible infinite recursion

c:\windows\desktop\c++ stuff\3d snake\vc\scene_control.cpp(2) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit

Error executing cl.exe.

Share this post


Link to post
Share on other sites
Rickmeister    182
Sounds like you have some headerfile that is including itself.

Wannabe
warning C4786: identifier was truncated to ''255'' characters in the debug information
Test.exe - 0 error(s), 76 warning(s)

Share this post


Link to post
Share on other sites
Jason2Jason    166
can that be done indirectly?

FILE1**********

#include "file2.cpp"

code here



FILE2*********

#include "file1.cpp"

code here

Is there a way to include a header file once (like gl.h) and its availible for all the files in a project?

-J

Share this post


Link to post
Share on other sites
Kylotan    9860
Never #include .CPP files. The example you just posted will give you an infinite loop such as the one your compiler complained of. And no, there''s no automatic way to have a header #included for every file.

Maybe reading this article will help. It explains more about what to #include and what not to.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions ]

Share this post


Link to post
Share on other sites
Xanth    122
My guess would be to just make the CPP files part of your "project" usually in IDEs there is a button called Add to Project or something like it.

struct Geek {
    void e_mail = belgedin@earthlink.net;
    void url;
    int age = 17;
};

Share this post


Link to post
Share on other sites
Jason2Jason    166
I did but it doesnt matter now, I''ve got half the problem sorted, have a look at my new thred!

http://gamedev.net/community/forums/topic.asp?topic_id=93536

-J

Share this post


Link to post
Share on other sites
Oluseyi    2103
quote:
Original post by Xanth
struct Geek {
    void e_mail = belgedin@earthlink.net;
    void url;
    int age = 17;
};

[offtopic]
Your Geek structure a.) will not compile, and b.) is susceptible to bugs. You can''t declare void variables, and it''s better for you to store age as an unsigned int (so it can never be negative).
[/offtopic]

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ ]
[ MS RTFM [MSDN] | SGI STL Docs | Boost ]
[ Google! | Asking Smart Questions | Jargon File ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
IndirectX    122
quote:
Original post by Oluseyi
[offtopic]
Your Geek structure a.) will not compile, and b.) is susceptible to bugs. You can''t declare void variables, and it''s better for you to store age as an unsigned int (so it can never be negative).
[/offtopic]


And e_mail should be a function [pointer], not a variable.

Share this post


Link to post
Share on other sites
Xanth    122
Heh, it''s not supposed to work.

struct Geek {
    void e_mail = belgedin@earthlink.net;
    void url;
    int age = 17;
};

Share this post


Link to post
Share on other sites