header-files

What is WINVER?

て烟熏妆下的殇ゞ 提交于 2019-11-26 16:40:05
问题 I was looking at some code and they had this line: #define WINVER 0x0501 in stdafx.h file? Why do you need to define WINVER ? How does it affect your code? Can someone please explain? 回答1: WINVER determines the minimum platform SDK required to build your application, which in turn will determine at compile time which routines are found by the headers. You can use this to verify, at compile time, that your application will work on Windows 2000 (0x0500), for example, or on Windows XP (0x0501).

Header guards in C++ and C

孤街醉人 提交于 2019-11-26 16:25:01
At LearnCpp.com | 1.10 — A first look at the preprocessor . Under Header guards , there are those code snippets: add.h: #include "mymath.h" int add(int x, int y); subtract.h: #include "mymath.h" int subtract(int x, int y); main.cpp: #include "add.h" #include "subtract.h" In implementing the header guard , it is mentioned as follows: #ifndef ADD_H #define ADD_H // your declarations here #endif What could the declaration be here? And, should int main() come after #endif ? Is adding _H a convention or a must do thing? Thanks. The Communist Duck The FILENAME_H is a convention. If you really wanted

Header file included only once in entire program?

梦想的初衷 提交于 2019-11-26 16:23:07
问题 I know this is a common question but I still can't fully get my head around it. In a C or C++ program generated from multiple different source and header files, will each header file be only included once in the entire code when the header guards are used? Someone told me previously that a header file (with include guards) will get included only once in one translation unit but multiple times in the entire code. Is this true? If it gets included only once throughout the entire code, when one

Header file inclusion static analysis tools?

妖精的绣舞 提交于 2019-11-26 15:47:39
问题 A colleague recently revealed to me that a single source file of ours includes over 3,400 headers during compile time. We have over 1,000 translation units that get compiled in a build, resulting in a huge performance penalty over headers that surely aren't all used. Are there any static analysis tools that would be able to shed light on the trees in such a forest, specifically giving us the ability to decide which ones we should work on paring out? UPDATE Found some interesting information

What's the differences between .dll , .lib, .h files?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 15:20:40
问题 Why in a project should I include some *.lib, .h or some other files? And what are these things used for? 回答1: .h : header file, its a source file containing declarations (as opposed to .cpp, .cxx, etc. containing implementations), .lib : static library may contain code or just links to a dynamic library. Either way it's compiled code that you link with your program. The static library is included in your .exe at link time. .dll : dynamic library. Just like a static one but you need to deploy

How can I create C header files [closed]

雨燕双飞 提交于 2019-11-26 14:59:56
问题 I want to be able to create a collection of functions in a header file that I could #include in one of my C Programs. 回答1: Open your favorite text editor Create a new file named whatever.h Put your function prototypes in it DONE. Example whatever.h #ifndef WHATEVER_H_INCLUDED #define WHATEVER_H_INCLUDED int f(int a); #endif Note: include guards (preprocessor commands) added thanks to luke. They avoid including the same header file twice in the same compilation. Another possibility (also

Variable definition in header files

旧时模样 提交于 2019-11-26 14:00:07
问题 My very basic knowledge of C and compilation process has gone rusty lately. I was trying to figure out answer to the following question but I could not connect compilation, link and pre-processing phase basics. A quick search on the Google did not help much either. So, I decided to come to the ultimate source of knowledge :) I know: Variables should not be defined in the .h files. Its ok to declare them there. Why: Because a header file might get included from multiple places, thus redefining

Including header files in C/C++ more than once [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-11-26 13:48:15
问题 This question already has an answer here: Is there any situation where you wouldn't want include guards? 6 answers Is it ever useful to include a header file more than once in C or C++? If the mechanism is never used, why would the compiler ever worry about including a file twice; if it really were useless, wouldn't it be more convenient if newer compilers made sure every header is included only once? Edit: I understand that there are standard ways of doing things like include guards and

Objective C to Swift header file with multiple targets

夙愿已清 提交于 2019-11-26 13:09:56
问题 I'm successfully calling my Swift classes from Objective C (for target 'MyApp') via the import statement: #import "MyApp-Swift.h" I've now created a new target called "MyAppLite" When I compile the new target, I get errors because "MyApp-Swift.h" is required by the code, but the compiler is creating "MyAppLite-Swift.h" So, I need to create a conditional Swift/ObjC header #import for the target I'm compiling against. How can this be done, or is there a better way? 回答1: It is also possible to

Difference between @interface definition in .h and .m file

喜欢而已 提交于 2019-11-26 12:55:41
Normally we use @interface interface_name : parent_class <delegates> { ...... } @end method in .h file and in .m file we synthesis the properties of variables declared in .h file. But in some code, this @interface.....@end method is kept in the .m file also. What does it mean? What is the difference between them? Also give some words about getters and setters for the interface file that is defined in .m file... Thanks in Advance Benedict Cohen It's common to put an additional @interface that defines a category containing private methods: Person.h: @interface Person { NSString *_name; }