visual studio 2010 - C++: Switching from MSVC to G++: Global Variables -


i switched linux , wanted compile visual studio 2010 c++ source code, uses stl, on g++.

my linux machine isn't available can try tell going on, first:

  • as try compile project, global variables use in main , work on msvc result in myglobalvar not defined in scope errors.

my project built same example below:

// myclass.h class myclass {  // .... }; extern myclass globalinstance;  // myclass.cpp #include "myclass.h" // myclass functions located here myclass globalinstance;  // main.cpp #include "myclass.h" int main( ) {     // accessing globalinstance results in error: not defined in scope } 
  • what doing wrong?
  • where differences between g++ , msvc in terms of global variables?

you need compile follow:

g++ main.cpp myclass.cpp -o myapp

not follow: g++ main.cpp -o myapp miss global variable declaration in myclass.cpp file.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -