header-files

undefined reference when calling inline function

青春壹個敷衍的年華 提交于 2019-11-27 07:57:35
I am getting a really odd error from GCC 4.8.1 with inline functions. I have two near-identical inline functions defined in header files ( debug.h and error.h ) in src/include/ , with the only difference being what they print - one prefixes DEBUG: to the message, and the other %s: error: %s (program name, error message). When defining the functions both inline, and compiling a debug build (so it sets the macro DEBUG=1 ), I get lots of undefined reference errors: src/main_debug.o gcc -osrc/main_debug.o src/main.c -c -Wall -Wextra -Wpedantic -std=gnu11 -march=native -Og -g -DCC="\"gcc\""

Objective C to Swift header file with multiple targets

丶灬走出姿态 提交于 2019-11-27 07:21:57
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? C0D3LIC1OU5 It is also possible to set the Product Module Name setting in Build Settings to be the same across your modules (I set

When is it useful to include the same header multiple times in one file? [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-11-27 06:57:53
问题 This question already has an answer here: Is there a case where including the same header twice is actually helpful? 6 answers I was reading about multiple inclusions of the same header in one file, and found an interesting statement (link): There are a couple of tricks with header files were you deliberately include it multiple times (this does actually provide a useful feature). I understand that those tricks are probably undesired and confusing in real-world projects (especially since

Self-sufficient header files in C/C++

扶醉桌前 提交于 2019-11-27 06:49:47
I recently posted a question asking for what actions would constitute the Zen of C++ . I received excellent answers, but I could not understand one recommendation: Make header files self-sufficient How do you ensure your header files are self-sufficient ? Any other advice or best-practice related to the design and implementation of header files in C/C++ will be welcome. Edit: I found this question which addresses the "Best Practices" part of mine. shoosh A self sufficient header file is one that doesn't depend on the context of where it is included to work correctly. If you make sure you

include stdafx.h in header or source file?

橙三吉。 提交于 2019-11-27 06:39:56
问题 I have a header file called stdafx.h and this one is precompiled of course. I've read that I should include these files into my .cpp files, but some of these statements are already needed in the header file coming with that. Should I add the stdafx into my header or into my cpp? I thought it was good practise to put it into the header, but I seem to be obliged to put it into the header instead. Example: stdafx contains freeglut. my class header file has an attribute of GLenum. Should I

How to make g++ search for header files in a specific directory?

雨燕双飞 提交于 2019-11-27 06:27:42
I have a project (a library) that is subdivided into a few directories with code in them. I'd like to to have g++ search for header files in the project's root directory, so I can avoid different include paths for same header files across multiple source files. Mainly, the root/ directory has sub-directories A/ , B/ and C/ , all of which have .hpp and .cpp files inside. If some source file in A wanted to include file.hpp , which was in B, it would have to do it like this: #include "../B/file.hpp" . Same for another source file that was in C. But, if A itself had sub-directories with files that

javac “no source files” when using -h option

99封情书 提交于 2019-11-27 06:14:04
问题 I'm trying to experiment with using the JNI and JDK 9. I have a class NativeTest.java that looks like this: public class NativeTest { static { System.loadLibrary("hello"); } private native void sayHello(); public static void main(String[] args) { new NativeTest().sayHello(); } } I compile the class, then use javah NativeTest to generate the header file. Upon issuing javah , I get this warning: Warning: The javah tool is planned to be removed in the next major JDK release. The tool has been

How do header and source files in C work?

喜欢而已 提交于 2019-11-27 06:08:38
I've perused the possible duplicates, however none of the answers there are sinking in. tl;dr: How are source and header files related in C ? Do projects sort out declaration/definition dependencies implicitly at build time? I'm trying to understand how the compiler understands the relationship between .c and .h files. Given these files: header.h : int returnSeven(void); source.c : int returnSeven(void){ return 7; } main.c : #include <stdio.h> #include <stdlib.h> #include "header.h" int main(void){ printf("%d", returnSeven()); return 0; } Will this mess compile? I'm currently doing my work in

How to fix “unable to open stdio.h in Turbo C” error?

拥有回忆 提交于 2019-11-27 06:08:09
问题 Whenever I compile my program, I get the error above. 回答1: If you have problems like that, first of all your TC folder put in to the C:..drive. after completing installation open turbo c blue screen. there is a OPTIONS > Directories ..in that you can see for option to set up path.. include directories..you can set path there now.. C:\TC\INCUDE libraries Directories..you can set path there... C:\TC\LIB if you want to store your output in BIN then you can set.. C:\TC\BIN ..otherwise you can set

Defining constructor in header file vs. implementation (.cpp) file

一个人想着一个人 提交于 2019-11-27 05:33:49
问题 I can define the body of a class constructor in the class .h file or in the implementation file .cpp . These two styles are probably identical as far as the compiler is concerned within a specific project (project for me means DLL ). Same applies to any member functions really: they can be defined in the header file or just declared there and then defined in the cpp file. However, I found that if I need to include such class header file(s) in different projects (meaning that ultimately the