Conflicting symbol name with library is not rare.
So, I want suggest my personal opinion to avoid this.
1. Before release code/library, change all symbol name of source code into unique name (random string) with tool.
2. Determine appropriate symbol name that should be exported.
(There can be two options. (*a)One is "changing exported symbols into agreed name". (*b)The other is "providing header file that includes all exported symbol with recommended name. And user can re-define necessary or conflicting symbol into expected one")
Let's see the example.
a. (original source code)
...
MY_UINT32 my_name;
...
MY_UINT16 company_name;
..
b. (symbol-changing-tool setting) - change symbol from 'a.'
...
MY_UINT32 => FooRgYaIIkdjdtq40238dkkRkwUTTT00001
MY_UINT16 => FooRgYaIIkdjdtq40238dkkRkwUTTT00002
my_name => FooRgYaIIkdjdtq40238dkkRkwUTTT00003
compay_name => FooRgYaIIkdjdtq40238dkkRkwUTTT00004
...
c. (auto-modified original source code)
...
FooRgYaIIkdjdtq40238dkkRkwUTTT00001 FooRgYaIIkdjdtq40238dkkRkwUTTT00003;
...
FooRgYaIIkdjdtq40238dkkRkwUTTT00002 FooRgYaIIkdjdtq40238dkkRkwUTTT00004;
...
-------- (*a) -------------
d1. agreed name
MY_UINT32 => UINT32
MY_UINT16 => UINT16
my_name => company_name
company_name => firm_name
d2(*a). (symbol-changing-too setting) - change symbol from 'c.' based on 'd.'
FooRgYaIIkdjdtq40238dkkRkwUTTT00001 => UINT32
FooRgYaIIkdjdtq40238dkkRkwUTTT00002 => UINT16
FooRgYaIIkdjdtq40238dkkRkwUTTT00003 => company_name
FooRgYaIIkdjdtq40238dkkRkwUTTT00004 => firm_name
---------- (*b) ---------
d. (header file that has recommended symbol)
/*symbol_match.h */
/*=============== symbol-matching table ================= */
...
#define UINT32 FooRgYaIIkdjdtq40238dkkRkwUTTT00001
#define UINT16 FooRgYaIIkdjdtq40238dkkRkwUTTT00002
#define my_name FooRgYaIIkdjdtq40238dkkRkwUTTT00003
#define company_name FooRgYaIIkdjdtq40238dkkRkwUTTT00004
...
--------------------
e. (Releasable code - base source code for building library)
...
UINT32 company_name;
...
UINT16 firm_name;
...
I think this way is worth considering to make very portable library.
'Language > C&C++' 카테고리의 다른 글
[C/C++] Case study! Bad example about endianness. (0) | 2007.06.29 |
---|---|
[C/C++] Sample! inter-change between endians... (0) | 2007.06.28 |
[C/C++] Using 'virtual' and 'inline' keywords simultaneously. (0) | 2007.04.04 |
[C/C++] virtual inheritance (0) | 2007.03.24 |
[C/C++] Remind! Multiple-Inheritance of same-named-method from two classes. (0) | 2007.03.18 |