0

When I posted this question about trying to build a DLL and not getting one, a commenter mentioned that I was probably not exporting any symbols in the project. When I checked, I found that the project file CMake had built didn't contain the .h file for the project, so I added it. It contains the needed export declarations. Unfortunately, rebuilding still doesn't generate a DLL, and after playing around a little, I find that the compiler doesn't seem to notice the .h file at all; when I write things in there that are obviously syntactically invalid, it doesn't even break the build.

Why is the compiler ignoring the .h file after I added it to the project, and how can I get it to compile properly?

Community
  • 1
  • 1
Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477

1 Answers1

2

The compiler will only translate a .h file if it is included in a translation unit (.c file) that it is building. Adding a reference to it the makefile does not in itself cause the .h file to be translated. If it is a target - there is no rule to build a .h file because it makes no sense. If it is a dependency, changes to it will cause the target to be built, but if the target does not include the header file, it is not a true dependency.

Another possibility is that the header is included but includes some conditional compilation that is not enabled.

Clifford
  • 88,407
  • 13
  • 85
  • 165
  • 1
    Ugh, right. I should have remembered that #include is all inline. Sorry; I'm too used to languages with real module systems. – Mason Wheeler Jan 31 '16 at 17:35