header-files

Xcode cannot find #Include<> header

こ雲淡風輕ζ 提交于 2019-12-05 23:55:26
问题 I'm trying to get Xcode to import the header file for Irrlicht. #include <irrlicht.h> It says "Irrlicht.h. No such file or directory". Yes Irrlicht.h with a capital I, even though the #include is lowercase. Anyway I added "/lib/irrlicht-1.6/include" in the header search paths for the Xcode project, yet it still doesn't find it. The only thing I've tried that does work is: #include "/lib/irrlicht-1.6/include/irrlicht.h" This is a bit ridiculous though, #include should work, I don't understand

Error “Unterminated conditional directive” in cross-referencing headers

懵懂的女人 提交于 2019-12-05 23:39:34
There are two classes that are related to each other in their headers: PlotMarker #ifndef PLOTMARKER_H #define PLOTMARKER_H #include <QObject> #include "plotter.h" class Plotter; class PlotMarker : public QObject { // ... Plotter* m_attachedPlot; // ... }; #endif // PLOTMARKER_H Plotter #ifndef PLOTTER_H #define PLOTTER_H // ... #include "plotmarker.h" // ... class PlotMarker; class Plotter : public QQuickPaintedItem { // ... QLinkedList<PlotMarker*> m_markerList; // ... }; #endif // PLOTTER_H The program is compiled well, but it's got a error error: unterminated conditional directive in

Why must we Forward Declare a class and include the corresponding header file in a header file

我与影子孤独终老i 提交于 2019-12-05 16:55:43
Hi I noticed if I include a header file in a .cpp then I can create an object of that header file's class. Like if I include A.h in main.cpp then I can write A *a; in main.cpp . But this doesn't work if I include a header file in another header file and then try to create the object of that included header file. Like, file B.h : #include "A.h" class B { public: B(){}; A *a; }; I have to add forward declaration of the class A to make it work. Why? Here are the basics: For any type A , if you declare a variable of type A& , A* , A** , A*** ,etc, then the compiler does not need to know the

- Default value of variables at the time of declaration -

孤人 提交于 2019-12-05 14:39:18
I was wondering what were the default values of variables before I initialized them... For example, if I do : //myClass.h BOOL myBOOL; // default value ? NSArray *myArray; // default value ? NSUInteger myInteger; // default value ? Some more examples here : //myClass.m // myArray is not initialized, only declared in .h file if ([myArray count] == 0) { // TRUE or FALSE ? // do whatever } More generally, what is returned when I do : [myObjectOnlyDeclaredAndNotInitialized myCustomFunction]; Thank you for your answers. Gotye. The answer is that it depends on the scope in which the variable is

undefined reference to <function name>

独自空忆成欢 提交于 2019-12-05 11:16:28
问题 I have this simple test file: #include "stack.h" int main() { Stack* stck = init_stack(); return 0; } and stack.h is defined as follows: #ifndef STACK_H #define STACK_H #define EMPTY_STACK -1 typedef struct stack { char ch; struct stack* prev; } Stack; extern Stack* init_stack(); extern char pop(Stack*); extern void push(Stack*, char); #endif These two files are in the same directory. But when I do gcc .. to build it, I keep getting the error below: $ ls stack.c stack.h teststack.c $ gcc -o

When is a header file required for using a static library?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 10:17:11
If I create a static library in C++ in Linux such that a ".a" file is produced, how do I (or anyone else) use the library? For example, my library defines a class. I assume that it is not sufficient merely to provide the ".a" file, but also to provide a header file. How do I know what header files must be provided with the ".a" file? For example, do I need to provide all header files that were included anywhere in the code for my library? Emilio Garavaglia The technical reason for header files is to let the compiler know about names and sizes while compiling user code, so that it can arrange

Windows <sys/file.h> equivalent

元气小坏坏 提交于 2019-12-05 08:55:00
Is there a Win32 equivalent to the linux header file? I'm working on a Linux to Windows port (and my first time doing so) and it's failing on this file. When writing WIN32API apps you usually #include <windows.h> - that includes most of the Windows API in your application. If you need to cut down on some of those includes, #define WIN32_LEAN_AND_MEAN will wipe out some of the more obscure things from the Windows libraries. What functions are you trying to convert? It'll probably be a case of using a different function on WIN32; it is very different to Linux/Unix/POSIX. Example: the ReadFile()

“‘sockaddr_in’ undeclared (first use in this function)” error despite including the requisite headers

蹲街弑〆低调 提交于 2019-12-05 08:44:07
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <unistd.h> #include <arpa/inet.h> #include <netdb.h> #include <unistd.h> #include <signal.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include <sys/time.h> #include <stdlib.h> #include <memory.h> #include <ifaddrs.h>#include <net/if.h> #include <stdarg.h> #define BACKLOG 10 void * get_in_addr(struct sockaddr *sa){ if(sa->sa_family == AF_INET){ return &((sockaddr_in *)sa)->sin_addr; } else if(sa->sa_family == AF_INET6){ return &((sockaddr_in6 *)sa)->sin6_addr; } } I am using the

G++ compiler error - Synthesized method first required here

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:14:52
Here's the error: In file included from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ios:39, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/ostream:40, from /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/iostream:40, from date.h:15, from date.cpp:13: /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/ios_base.h: In copy constructor ‘std::basic_ios<char, std::char_traits<char> >::basic_ios(const std::basic_ios<char, std::char_traits<char> >&)’: /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../..

Is it unspecified whether a standard library header includes arbitrary headers?

纵饮孤独 提交于 2019-12-05 03:32:16
There is a claim in Which headers in the C++ standard library are guaranteed to include another header? : The C++ standard library headers may include each other in unspecified ways, so programmers generally shouldn't depend on one header including another. [...] In practice this tends to be the case. For example, <iostream> may include <string> , in other cases you need to include <string> explicitly. However, I can't seem to find where in N4140 this is the case. I've looked in: §2.9 [lex.header] §17.6.1.2 [headers] §17.6.2.2 [using.headers] §17.6.4.4 [alt.headers] §17.6.5.2 [res.on.headers]