header-files

Cmake not handling header files build dependencies if build dir is a subdirectory of PROJECT_SOURCE_DIR?

≯℡__Kan透↙ 提交于 2020-02-06 07:58:33
问题 The accepted answer of this question correctly states that cmake does not handle C++ header-files build dependencies in case cmake's build directory is under cmake's PROJECT_SOURCE_DIR . PROJECT_SOURCE_DIR is assigned its value when the cmake project() macro is used, therefore it would be the "top" directory for such a project structure using project(source) : top | |--CmakeLists.txt |--source |--build As far as I know, this is the typical structure of a cmake project, so I find it surprising

C++ Do I have to include standard libraries for every source file?

↘锁芯ラ 提交于 2020-02-01 02:53:48
问题 I'm a bit confused at the moment because I'm planning to include multiple source and header files for the first time in one of my projects. So I'm wondering if this would be the right approach? Do I have to include the string header in every source file that uses it directly? And what about the "stdafx.hpp" header that Visual C++ wants me to include? Would that be the way to go? main.cpp #include "stdafx.hpp" #include <string> //? #include <stringLib1.h> #include <stringLib2.h> using std:

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

旧城冷巷雨未停 提交于 2020-01-31 03:17:05
问题 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? 回答1: For a start, it would be unusual to have a main.h since there's usually nothing that needs to be exposed to the other compilation units at compile time. The main() function

dos.h for Linux?

牧云@^-^@ 提交于 2020-01-28 10:48:13
问题 I have a C program which contains #include <dos.h> header. It shows a compile time error. I know that the dos.h header file is not valid in Linux. Is there any other equivalent header for dos.h in Linux? 回答1: dos.h header file is interface to the DOS operating system. They are not portable to operating systems other than DOS (means not works in Linux). Which functionality in dos.h you are going to use? 回答2: Linux is a Posix/Unix like system, so you should learn the system calls and facilities

dos.h for Linux?

蹲街弑〆低调 提交于 2020-01-28 10:47:20
问题 I have a C program which contains #include <dos.h> header. It shows a compile time error. I know that the dos.h header file is not valid in Linux. Is there any other equivalent header for dos.h in Linux? 回答1: dos.h header file is interface to the DOS operating system. They are not portable to operating systems other than DOS (means not works in Linux). Which functionality in dos.h you are going to use? 回答2: Linux is a Posix/Unix like system, so you should learn the system calls and facilities

Static assertion failed with “Windows headers require the default packing option…”

佐手、 提交于 2020-01-25 01:58:12
问题 When I'm trying to compile my C++ project in Visual Studio, I keep getting the 2 following errors: E1574: Static assertion failed with "Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined." and C2338: Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE

C++ Syntax Header File Errors

房东的猫 提交于 2020-01-20 09:16:30
问题 I am using opencv and gdal with visual studio 2019 community version, I writte some sample test to know if opencv and gdal works fine on my computer, but then some error with header file raises, all these error didn't affect the compiling of the program and the running or output of the program, all is fine except those header file syntax error, which makes me really confused. my code is down below: /*opencv_test*/ #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp>

C++ Syntax Header File Errors

孤街醉人 提交于 2020-01-20 09:15:35
问题 I am using opencv and gdal with visual studio 2019 community version, I writte some sample test to know if opencv and gdal works fine on my computer, but then some error with header file raises, all these error didn't affect the compiling of the program and the running or output of the program, all is fine except those header file syntax error, which makes me really confused. my code is down below: /*opencv_test*/ #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp>

How to prints the built in functions name used in our program using a specific header file in C?

点点圈 提交于 2020-01-17 06:01:09
问题 I need to find the built-in functions used in our program from a specific header file. For example, I have the C file below: #include<stdio.h> int main() { int a; scanf("%d",&a); printf("a = %d\n", a); } If I given the stdio.h header file to any command, it needs to give the output as below: scanf printf Is there any built-in command to get this? Or any options available in the gcc or cc command to get this? 回答1: If you are using GCC as compiler, you can run this command: echo "#include

C How to manage #include relationship among multiple source files and create correct makefile

谁都会走 提交于 2020-01-16 19:29:40
问题 I again re-edited my question and this time it is final. note: the program is working (thanks for all the help). But I still have some confusion about how the dependency/linkage actually works. Specifically I would like to be walked through the process that the makefile compiles and runs. (example, the compiler first looks at main.c, starting from line 1, which is main.h, goes into main.h, starting from line 1, which points to function1.h, and so on.) My main question here is though: is it