global vars in DLL

Hi I have some code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>

/*  To use this exported function of dll, include this header
 *  in your project.
 */

#ifdef BUILD_DLL
    #define DLL_EXPORT __declspec(dllexport)
#else
    #define DLL_EXPORT __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C"
{
#endif

int DLL_EXPORT global = 2;

int DLL_EXPORT SomeFunction()
{
 global=+4;
 return global;
}
// a sample exported function
int DLL_EXPORT SomeFunction();
#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__ 



And when I use compiled DLL SomeFunction return 4 (not 6).
What should I do to get 6? I want to use global vars for many functions.
You mixed up the order "=+" should be "+=" on line 25
Thanks very much!! It's working!!
Topic archived. No new replies allowed.