简体   繁体   中英

Using the same header files as those in static library

如果源文件中包含的头文件(.h)也已包含在静态库(.lib)中,将会发生什么?

A typical library implementation will include its own header, so this is not a particularly special case.

If the header declares things like global static variables, you of course can't define them more than once. Typically a library will include definitions for the data it declares (or, better, not declare any static global data) so your code that uses the library shouldn't duplicate those.

I don't think anything will happen unless some objects have been instantiated in the header file:

ie:

CMyStringType superMansName("Clark Kent");

Will result in a link error where the object exists in both the static library and your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM