MantisBT - CMake
View Issue Details
0015549CMakeCMakepublic2015-04-30 08:012016-06-10 14:31
Micha Renner 
Kitware Robot 
normalminoralways
closedmoved 
Windows
CMake 3.2.1 
 
0015549: GenerateExportHeader: The extern keyword and data symbols
It seems that the "extern" keyword is much more important than previously thought, at least for the MSVC in connection with static libraries.

The example in the appendix demonstrates this.


- build this project
- run the program => wrong output

- open the tlib_export.h file in the CMAKE_BINARY_DIR:
    - change:
      #ifdef TLIB_STATIC_DEFINE
      # define TLIB_EXPORT
      to
      #ifdef TLIB_STATIC_DEFINE
      # define TLIB_EXPORT extern
- build the project again
- run the program => correct results.

May be one can change the GENERATE_EXPORT_HEADER macro to add the extern keyword automaticlly .

(example is taken from the ffi library)
No tags attached.
zip example.zip (7,701) 2015-04-30 08:01
https://public.kitware.com/Bug/file/5445/example.zip
Issue History
2015-04-30 08:01Micha RennerNew Issue
2015-04-30 08:01Micha RennerFile Added: example.zip
2015-04-30 09:50Brad KingSummaryThe extern keyword => GenerateExportHeader: The extern keyword and data symbols
2015-04-30 09:52Brad KingNote Added: 0038655
2016-06-10 14:29Kitware RobotNote Added: 0042770
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0038655)
Brad King   
2015-04-30 09:52   
For reference, an explicit 'extern' linkage specifier is needed when declaring global variables. For functions it does not matter because the compiler knows it is a declaration rather than a definition when no function body is present.
(0042770)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.