I have a header file foo.h:
#ifndef __FOO_H__
#define __FOO_H__
const char* USB_MANAGER_DBUS_SERVICE =  "com.USBService";
#define  USB_MANAGER_DBUS_OBJ_PATH  "/com/USB/MgrObject"
const int  DBUS_CONNECTION_MAX_RETRY_TIME  = 5;
#endif
And many cpp files that includes foo.h.
foo.c bar.c
When compiling them together, "multiple definition error" appears.
Linking CXX shared library:
foo.cpp.o:(.data.rel.local+0x0): multiple definition of `USB_MANAGER_DBUS_SERVICE'
bar.cpp.o:(.data.rel.local+0x0): first defined here
So I have two questions below:
- Why doesn't #definelead to a link error?
- Why doesn't const intlead to a link error?
 
     
     
     
     
     
     
    