Advertisement

Can anyone explain this error?

Started by January 16, 2001 11:43 AM
2 comments, last by Ataru 24 years ago
I''ve been working with DX8 and I''m getting stupid linker errors. I don''t mind bugs, but I hate bugs related to linking. Here''s my problem, if anyone has a suggestion it would be greatly appreciated: I have a header file: #ifndef VERTEX_H #define VERTEX_H typedef struct vertex_s { float x,y,z; DWORD color; float tu,tv; } vertex; vertex *vertices; WORD *indices; #endif And one file has a #include "vertex.h", everything compiles fine. But if i have another file in my project that also includes vertex.h I get the following errors: fractal.cpp d:\4080\fract_ter\vertex.h(7) : error C2146: syntax error : missing '';'' before identifier ''color'' d:\4080\fract_ter\vertex.h(7) : error C2501: ''DWORD'' : missing storage-class or type specifiers d:\4080\fract_ter\vertex.h(7) : error C2501: ''color'' : missing storage-class or type specifiers d:\4080\fract_ter\vertex.h(13) : error C2143: syntax error : missing '';'' before ''*'' d:\4080\fract_ter\vertex.h(13) : error C2501: ''WORD'' : missing storage-class or type specifiers d:\4080\fract_ter\vertex.h(13) : error C2501: ''indices'' : missing storage-class or type specifiers anyone have any suggestions? Thanks in advance.
vertex *vertices;
WORD *indices;

You should never declare variables in header files -- this will cause some conflicts. Just declare them in a CPP file, and write

extern vertex *vertices;
extern WORD *indices;

in your header file -- that will make it possible for everyone to access the variables...

... but I don''t think that''s the only problem.
-- Rasmus Neckelmann
Advertisement
Have you included windows.h in your sources before using DWORD, WORD, and so on?

Kurie
Kurie Itoh
I think it''s because the compiler doesn''t know what a DWORD is. And as far as I know, DWORD is defined somewhere in the windows header files. Try including <windows.h> in your header file.

And yes, don''t declare variables in your header files, except if you''re looking for trouble . Better to declare them external in the header, and declare them for real in some source file, like kadaf said.

Dormeur
Wout "Dormeur" NeirynckThe Delta Quadrant Development Page

This topic is closed to new replies.

Advertisement