Archived

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

Sickilla

externals

Recommended Posts

what exactly is an ''extern'' in c++? for example: extern LPDIRECTDRAW7 lpdd; and also what does the error UNRESOLVED EXTERNALS mean? TOTWGPG uses these alot but never really explains what they are or do. I think it is the source of my error. X4J

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Sickilla
what exactly is an ''extern'' in c++? for example:
extern LPDIRECTDRAW7 lpdd;



Extern in c is a variable/function that may be defined in a source file other than the one it is referenced/used. Its name is visible from files other than the one in which it''s defined. This means, that you''re able to initialise lpdd in one source file and use it in all of the other ones.

quote:

and also what does the error UNRESOLVED EXTERNALS mean?



Unresolved externals are, hm, unresolved externals Seriously, it means that you declared a var/func external but you did not defined it (e.g. LPDIRECTDRAW7 lpdd; somewhere in main.cpp).

For a deeper explanation of the keyword external consult your favourite c/c++ book or the msdn.

Hope this helps,
Bjørn.

Share this post


Link to post
Share on other sites
quote:
Original post by Sickilla
what exactly is an ''extern'' in c++? for example:
extern LPDIRECTDRAW7 lpdd;

and also what does the error UNRESOLVED EXTERNALS mean?

TOTWGPG uses these alot but never really explains what they are or do. I think it is the source of my error.

X4J


Here''s an example as I can''t seem to find the word to explain it:

This here should be in a .h file along with other DX stuff.

extern LPDIRECTDRAW7 lpdd;


in your main ".cpp" file you would have:

LPDIRECTDRAW7 lpdd;

Basicly, external variables are a way of telling the compiler that a variable that you want to use is declared elsewhere in your project. ( I finally found the words )... Now, as for your error, it''s simple, you don''t have the real declaration anywhere in your project. That''s why it''s telling you UNRESOLVED EXTERNAL. Hope this helps...

Share this post


Link to post
Share on other sites
quote:
Original post by Sickilla
what exactly is an ''extern'' in c++? for example:
extern LPDIRECTDRAW7 lpdd;

and also what does the error UNRESOLVED EXTERNALS mean?

TOTWGPG uses these alot but never really explains what they are or do. I think it is the source of my error.

X4J


Here''s an example as I can''t seem to find the word to explain it:

This here should be in a .h file along with other DX stuff.

extern LPDIRECTDRAW7 lpdd;


in your main ".cpp" file you would have:

LPDIRECTDRAW7 lpdd;

Basicly, external variables are a way of telling the compiler that a variable that you want to use is declared elsewhere in your project. ( I finally found the words )... Now, as for your error, it''s simple, you don''t have the real declaration anywhere in your project. That''s why it''s telling you UNRESOLVED EXTERNAL. Hope this helps...



"And that''s the bottom line cause I said so!"

Cyberdrek
Headhunter Soft
A division of DLC Multimedia

Resist Windows XP''s Invasive Production Activation Technology!

Share this post


Link to post
Share on other sites