Linking my code

Started by
2 comments, last by martinjy 22 years, 1 month ago
Hi there... I''m not very good at c++ coding, so I guess this is pretty elementary: I use several .cpp files and one header file for my project (VC6.0). My header starts off with #if !defined _OPENGL_H_ #define _OPENGL_H_ and is terminated with #endif. Then I try to put universal variables and stuff here. Still, the compiler complains about for example "hWnd already defined in OpenGL.lib. But that''s not tru! I have not defined it twice. What is wrong?
Martin Jynge
Advertisement
I had a certain relational problem like this with Dev-C++ v5.0 beta, but I did issue it twice*I didn''t know untill the darn errors came up*, try using the include:
#include "filenamehere.h" put change the "filenamehere" to the filename, and change the ".h" to a .h, .hpp, or something like that

If you care about her/him, you''''ll listen
If you love her/him, you''''ll heal his/her wounds
If you like her/him, you''''ll do all of the above, and help her/him in need

A person who cares is a person who never speaks
You can also put "#pragma once" at the top of the header file.
Don''t declare variables in header files. Declare them in source files. Put extern references in the header file so that the variable becomes visible in all files that include the header.

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

This topic is closed to new replies.

Advertisement