General discussion

Locked

Linker errors

By parag_pathak ·
A have made a program in c most of the line use # directives & also declare a extern variable & include this program in other program(2) but the compilation of program(2) gives the linker errors of not finding that globlly defined extern variable(which i have told u about).

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Linker errors

by marobertson In reply to Linker errors

If I understand correctly, you have a program that consists of multiple modules, and want to have a global variable shared by all of them. To do that, you need to define the variable in one .cpp file like this;

double value;

and in all the other .cpp files like this:

extern double value;

The "extern" tells the compiler that the symbol will be available at link time from another module

Hope this helps

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums