View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015549CMakeCMakepublic2015-04-30 08:012016-06-10 14:31
ReporterMicha Renner 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformWindowsOSOS Version
Product VersionCMake 3.2.1 
Target VersionFixed in Version 
Summary0015549: GenerateExportHeader: The extern keyword and data symbols
DescriptionIt 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.


Steps To Reproduce- 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.

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

(example is taken from the ffi library)
TagsNo tags attached.
Attached Fileszip file icon example.zip [^] (7,701 bytes) 2015-04-30 08:01

 Relationships

  Notes
(0038655)
Brad King (manager)
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 (administrator)
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.

 Issue History
Date Modified Username Field Change
2015-04-30 08:01 Micha Renner New Issue
2015-04-30 08:01 Micha Renner File Added: example.zip
2015-04-30 09:50 Brad King Summary The extern keyword => GenerateExportHeader: The extern keyword and data symbols
2015-04-30 09:52 Brad King Note Added: 0038655
2016-06-10 14:29 Kitware Robot Note Added: 0042770
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team