header-files

How to avoid #include dependency to external library

╄→гoц情女王★ 提交于 2019-12-03 07:18:48
问题 If I'm creating a static library with a header file such as this: // Myfile.h #include "SomeHeaderFile.h" // External library Class MyClass { // My code }; Within my own project I can tell the compiler (in my case, Visual Studio) where to look for SomeHeaderFile.h. However, I don't want my users to be concerned with this - they should be able to include my header without having to inform their compiler about the location of SomeHeaderFile.h. How is this type of situation normally handled? 回答1

Find python header path from within python?

≯℡__Kan透↙ 提交于 2019-12-03 07:15:44
What is the equivalent of numpy.get_include() as used here for Python, giving me the path to the directory where the Python header files are located? The header files are in include directory. You can find the include dir using the distutils.sysconfig module from distutils.sysconfig import get_python_inc get_python_inc() #this gives the include dir You can read about it here 来源: https://stackoverflow.com/questions/14375222/find-python-header-path-from-within-python

Where are the opencv2 include files?

时光毁灭记忆、已成空白 提交于 2019-12-03 06:53:49
问题 I'm struggling to find the include files that should be in a directory names "opencv2"! I've downloaded OpenCV-2.4.0.tar.bz2 from here and extracted the files and ran cmake, which seemed to build the library successfully. The problem is that under the "include" directory for "opencv2" there seem to be tons of header files missing. The only header file there at the moment is "opencv.hpp", which includes a whole set of other files which aren't there. Does anyone have any idea where I can get

How to define an array of strings of characters in header file?

≯℡__Kan透↙ 提交于 2019-12-03 06:05:30
I have many different 3 axis sensors I am writing test code for. In the C files for each of them, I have the same char string defined: char axis[3][8] = {"X", "Y", "Z"} which I use when I "for" loop results to print the axis that is failing like this: DEVICETEST_LOG("%s Failed %s axis for Min range\n",device_name[DUT], axis[i]); I was thinking to save some space I could define a character string array in a header file to use all over the place. I have tried a number of things, but I can't seem to get an array of strings defined in my header file that I can iterate through to pass a compile. In

C++, how to declare a struct in a header file

我的未来我决定 提交于 2019-12-03 05:44:06
问题 I've been trying to include a structure called "student" in a student.h file, but I'm not quite sure how to do it. My student.h file code consists of entirely: #include<string> using namespace std; struct Student; while the student.cpp file consists of entirely: #include<string> using namespace std; struct Student { string lastName, firstName; //long list of other strings... just strings though }; Unfortunately, files that use #include "student.h" come up with numerous errors like error C2027

Cross-Platform C++ code and single header - multiple implementations

守給你的承諾、 提交于 2019-12-03 05:06:54
问题 I have heard that a way to write Cross Platform c++ code is to define classes as follows (for example, a Window class): window.h window_win32.cpp window_linux.cpp window_osx.cpp and then choose the implementation file accordingly. But what if i have members of that class that are relative to the os? Like a HWND member for the Win32 implementation. I can't put it in the window.h or when i'd try to compile it on, say, Linux, it'd generate a compiler error. Do i need to #ifdef it? I've already

How to use C code in C++

自古美人都是妖i 提交于 2019-12-03 02:42:47
问题 Just a small question: Can C++ use C header files in a program? This might be a weird question, basically I need to use the source code from other program (made in C language) in a C++ one. Is there any difference between both header files in general? Maybe if I change some libraries... I hope you can help me. 回答1: Yes, you can include C headers in C++ code. It's normal to add this: #ifdef __cplusplus extern "C" { #endif // C header here #ifdef __cplusplus } #endif so that the C++ compiler

Should every C or C++ file have an associated header file?

余生颓废 提交于 2019-12-03 02:20:45
Should every .C or .cpp file should have a header (.h) file for it? Suppose there are following C files : Main.C Func1.C Func2.C Func3.C where main() is in Main.C file. Should there be four header files Main.h Func1.h Func2.h Func3.h Or there should be only one header file for all .C files? What is a better approach? It's unusual to have a main.h since there's usually nothing that needs to be exposed to the other compilation units at compile time. main() itself needs to be exposed for the linker/start-up-code but they don't use header files. You can have either one header file per C file or,

xCode 4.4 does not get all the .pch file headers imports?

烈酒焚心 提交于 2019-12-03 02:20:11
问题 This is my .pch file - // // Prefix header for all source files of the 'English Club' target in the 'English Club' project // #import <Availability.h> #ifndef __IPHONE_4_0 #warning "This project uses features only available in iOS SDK 4.0 and later." #endif #ifdef __OBJC__ #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> #import "Helper.h" #import "Animations.h" #import "Constants.h" #import "SoundPlayer.h" #import "UAirship.h" #import "UAStoreFront.h"

Using a struct in a header file “unknown type” error

偶尔善良 提交于 2019-12-03 02:03:38
I am using Kdevelop in Kubuntu. I have declared a structure in my datasetup.h file: #ifndef A_H #define A_H struct georeg_val { int p; double h; double hfov; double vfov; }; #endif Now when I use it in my main.c file int main() { georeg_val gval; read_data(gval); //this is in a .cpp file } I get the following error: georeg_chain.c:7:3: error: unknown type name 'georeg_val' (This is in the georeg_val gval; line) I would appreciate if anyone could help me resolve this error. In C one has two possibilities to declare structure: struct STRUCT_NAME {} ; or typedef struct {} STRUCT_ALIAS; If you use