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 inmyglobalvar 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
Post a Comment