Multiple C++ files -- OpenGL, the END?????

Hello (NB i’m french !)

Yes, firt i have heard that Opengl was going to be replaced by D3D or something like that !
Is that right!!!
I hope no because i hate D3D.

Next, when i want to create multiple CPP files for my OpenGL prog, it don’t work.

Error : “one or more multiply defined symbols found”

I have 3 Files :
file1.cpp
file2.cpp
module.h

In file1.cpp i have :
#include “module.h”
#include “file2.cpp”

In file2 i have :
#include “module.h”

In module.h i have :

#ifndef module_h
#define module_h
#include <iostream.h>

#include <math.h>

#endif

How can i make that??

Thanks.

Yes, firt i have heard that Opengl was going to be replaced by D3D or something like that !
Is that right!!!
I hope no because i hate D3D.

Shoundn’t even comment that one, but I do anyway. What about OpenGL for UNIX-like OS’s? Seen Direct3D for UNIX yet? Hope that answered your question.

You include “module.h” twice in “file1.cpp”. First directly, and the second time through “file2.cpp” which also includes “module.h”.

You need some way to prevent the file from getting included twice. This is the most common way.

#ifndef SOME_NAME
#define SOME_NAME

// include file contents here

#endif

If the file is included twice, the second instance is removed by the preprocessor due to the #ifndef/#endif lines.

Never do this:

#include “file2.cpp”

Salut,

Regardes sur mon site, j’ai quelques programmes qui utilisent plusieurs CPP.
http://ibelgique.ifrance.com/Slug-Production