header-files

C++ Circular Dependency in Header Files

江枫思渺然 提交于 2019-12-17 17:14:33
问题 Is it possible to avoid circular dependency in the following header files without turning data member b1 in class A to a pointer/reference, and without relaxing the inline function requirement in class B ? A.h: #ifndef A_H #define A_H #include <B.h> // Required, as data member b1 is not a pointer/reference class A { public: B b1; // I want to keep this as as it is. int m_a; }; #endif B.h: #ifndef B_H #define B_H #include <A.h> // Required, as f() calls a member function of class A class B {

C++ Circular Dependency in Header Files

試著忘記壹切 提交于 2019-12-17 17:13:00
问题 Is it possible to avoid circular dependency in the following header files without turning data member b1 in class A to a pointer/reference, and without relaxing the inline function requirement in class B ? A.h: #ifndef A_H #define A_H #include <B.h> // Required, as data member b1 is not a pointer/reference class A { public: B b1; // I want to keep this as as it is. int m_a; }; #endif B.h: #ifndef B_H #define B_H #include <A.h> // Required, as f() calls a member function of class A class B {

Parsing / reading C-Header files using Java

这一生的挚爱 提交于 2019-12-17 15:52:11
问题 I have a C-Header file defining a couple of stucts, containing multiple char arrays. I'd like to parse these files using Java. Is there a library for reading C-Header files either into a structure or is there a stream parser that understands C-Header files? Just for more background (I'm just looking for a C-Header parser, not a solution for this particular problem): I have a text file containing data and a C-Header file explaining the structure. Both are a bit dynamic, so I don't want to

Where to document functions in C or C++? [closed]

為{幸葍}努か 提交于 2019-12-17 15:38:27
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I have a C program with multiple files, so I have, for example, stuff.c which implements a few functions, and stuff.h with the function prototypes. How should I go about documenting the functions in comments? Should I have all the docs in the header file, all the docs in the .c

Should I include stddef.h or cstddef for size_t

风格不统一 提交于 2019-12-17 10:58:55
问题 When I want to use size_t in C++, should I include <stddef.h> or <cstddef> ? I have heard several people saying that <cstddef> was a bad idea, and it should be deprecated. Why is that? 回答1: I prefer #include <stddef.h> . Some of the names in the C headers are allowed to be macros, but the set differs from the C rules. In C, EXIT_FAILURE , isdigit() , getc() a.o. are macros. Do you know which ones are macros in C++? Secondly, only a couple standard C headers are required to have the <cfoo>

Eclipse CDT: Unresolved inclusion of stl header

删除回忆录丶 提交于 2019-12-17 10:35:09
问题 I'm trying to use Eclipse to edit sources, compiled under C++ Builder, but stuck with Unresolved inclusion problem. For example, code like: #include <vector> Gives Unresolved inclusion: <vector> error in Eclipse IDE. C++ Builder indeed has no vector file, instead it has vector.h which is used by compiler. Eclipse IDE gives no error if I write #include <vector.h> How do I tell Eclipse to use vector.h when it sees #include <vector> ? 回答1: This allowed me to avoid Eclipse "Unresolved inclusion"

Is is a good practice to put the definition of C++ classes into the header file?

牧云@^-^@ 提交于 2019-12-17 10:22:45
问题 When we design classes in Java, Vala, or C# we put the definition and declaration in the same source file. But in C++ it is traditionally preferred to separate the definition and declaration in two or more files. What happens if I just use a header file and put everything into it, like Java? Is there a performance penalty or something? 回答1: The answer depends on what kind of class you're creating. C++'s compilation model dates back to the days of C, and so its method of importing data from

Where to find the complete definition of off_t type?

为君一笑 提交于 2019-12-17 10:18:20
问题 I am sending file from client to server using TCP. To mark the end of the file I like to send file size before the actual data. So I use stat system call to find the size of the file. This is of type off_t . I like to know how many bytes it occupies so that I can read it properly on the server side. It is defined in the <sys/types.h> . But I do not understand the definition. It just defines __off_t or _off64_t to be off_t . Where to look for __off_t ? Also is it convention that __ is prefixed

Installation of Visual Studio 2010 (any edition) installs only 2 files in the C++ headers directory

Deadly 提交于 2019-12-17 05:53:15
问题 I installed Visual Studio 2010 Premium on my Windows 7 workstation. After loading a test C++ project, I noticed that it could not locate iostream. I took a look in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include and noticed that only two files exist here, srv.h and wmiatlprov.h I installed the VS2010 product on a test virtual machine, and this directory ( ...\VC\include ) is filled with the usual collection of folders and headers (the materials you'd expect to find in the

Tools to find included headers which are unused? [closed]

一曲冷凌霜 提交于 2019-12-17 04:47:53
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I know PC-Lint can tell you about headers which are included but not used. Are there any other tools that can do this, preferably on linux? We have a large codebase that through the last 15 years has seen plenty of functionality move around, but rarely do the leftover #include directives get removed when