Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
83 views

Where to insert an #include when multiple files need it C++

Let's say I have 4 source files main, aux1, aux2 and aux3, all of whom work with strings and therefore need to #include <string>. The main one will include the 3 aux, since it will use it's ...
pbl's user avatar
  • 27
1 vote
0 answers
143 views

How to disable inclusion of header when using `#pragma once` (similiary to when using include guards)?

From time to time I have to retrofit unit testing into an unfriendly environment. In these cases include guards are pretty useful, because: I could suppress inclusion of unwanted header file, I could ...
uuu777's user avatar
  • 891
0 votes
0 answers
36 views

Is using #include partway through a Class declaration bad practice?

So, while working on a binary search tree (BST) class, I implemented a nested Node class within the BST's header file. As the Node class grew I wanted to declutter said header file, so I moved the ...
Patrick vD's user avatar
1 vote
3 answers
2k views

should pragma once be on top of every header as default

I'm learning C++ and I have encountered (and fix) what seems to be a very classic problem : g++ main.cpp A.cpp B.cpp -o out In file included from B.h:1, from main.cpp:3: A.h:1:7: ...
NRagot's user avatar
  • 194
1 vote
1 answer
316 views

include std map inside pragma pack causes crash

I was wondering why inclusion of std map inside pragma pack (1) causes segmentation fault? Does std map includes bit fields? The seg fault occurs on the second insert to the map at "std::less::...
doofx's user avatar
  • 71
4 votes
1 answer
4k views

HLSL #pragma once equivalent?

What's the equivalent to C/C++-like #pragma once in HLSL includes? I want (as a contrived example): // ./dependency.hlsl float x() { return 0; } // ./shader.hlsl #include "./dependency.hlsl" // (./ ...
Warty's user avatar
  • 7,385
0 votes
1 answer
10k views

error LNK2005 struct already defined in .obj file [closed]

I've been trying to deal with an issue regarding compilation units. The error I am getting is 1>frtinvxml.obj : error LNK2005: "struct repFieldInfo det_rep_info" (?det_rep_info@@3UrepFieldInfo@@...
Ian's user avatar
  • 695
0 votes
2 answers
203 views

Include a #pragma diagnostic ignored to a #define

I want to make a small define for my project. That define should just execute a code if its above an ios version. It looks like this #define IF_OS_8_OR_LATER(CODE) \ if([[[UIDevice currentDevice] ...
Martin Mlostek's user avatar
0 votes
2 answers
393 views

Understanding headers and include

I am trying to grasp how actually multiple definitions of include files collaborate and sometimes collide. So I have a custom header file file.h, where some functions are declared within an #include ...
Dimitar's user avatar
  • 4,743
0 votes
0 answers
292 views

What #include to use for using Vector3 in MSDN c++

I am trying to implement rotation in and the MSDN document has suggested everywhere to use Vector3 structure to achieve this. However I get an error for both Vector3 and Quaternion saying identifier ...
annie1994's user avatar
  • 143
23 votes
1 answer
10k views

How to make CLion use "#pragma once" instead of "ifndef ... def ..." by default for new header files?

By default, CLion will add the following lines to a newly created header file: #ifndef SOME_NAME_H #define SOME_NAME_H .... your code here #endif //SOME_NAME_H But I like #pragma once more. How can ...
a06e's user avatar
  • 20.6k
6 votes
3 answers
8k views

When to use include guards or #pragma once C++ [closed]

Is it good practice to use your choice of either/both include guards and #pragma once in every header file, or just those with something such as a class declaration? I am tempted to put it in every ...
Matthew D. Scholefield's user avatar
0 votes
1 answer
115 views

Error Link2005 in visual 2005

I wrote a c program in Visual C++. test2.cpp #pragma startup pragmaEgFun1 void pragmaEgFun1(){ printf("Hello 1"); } test1.cpp #include "test2.cpp" int main{ printf("...
CODError's user avatar
  • 779
0 votes
1 answer
468 views

Including many header files together without producing errors

i have a bit of a tricky problem here. I have 3 classes: agent, campaign, and sale - and they all need to include each other, how can i do this without causing a million errors in VS, I've already ...
MathMajor's user avatar
  • 279
4 votes
3 answers
4k views

Can the pre-processor directives like #include be placed only at the top of the program code?

I have used the #pragma directive inside functions without error or warning(especially #pragma pack()).But the following code shows the warning incompatible implicit declaration of built-in function '...
Rüppell's Vulture's user avatar
0 votes
1 answer
285 views

Gwan include scripts

I am currently trying to import some libraries into my Gwan C script. I have read through the manual and am using #pragma include to include the folder that my libraries are in, and then use #pragma ...
John-Alan's user avatar
  • 171
1 vote
2 answers
347 views

g-wan: building library outside of /csp, and g++ compilation problems

I am giving Gwan a whirl. Having made it through example code, I started a small project with more than one source file. I now have two problems: I got a linking error at server startup: Linking ...
Gabe Rainbow's user avatar
  • 3,738
1 vote
2 answers
9k views

#pragma once and #include issues

I had an issue of circular references (i.e. A.h and B.h #including each other) and some people advised me to use #pragma once to prevent that. However, this solution appears to be not working still. ...
Some Newbie's user avatar
  • 1,069
19 votes
6 answers
15k views

Is there a pragma directive for include directories?

As the title says: Is there a pragma directive for include directories using VS20** C++? I think about something like: #pragma comment(include, "..\externals\blah\includes\") So that I can use ...
Christoph Meißner's user avatar
5 votes
3 answers
5k views

OpenGL / GLSL - using glShaderSource with multiple source to support include files

Since GLSL doesn't have an include-file option I'm trying to add this by using a "#pragma include" parser. (I want this because I have some generic methods I'd like to implement only once but might ...
Pygmy's user avatar
  • 1,268
3 votes
2 answers
2k views

C++ Specify Headers Include Directory in Code

Is there a way to specify include directories in the code, perhaps via a #pragma? I have my project setup as "src/" and "include/" folders. I am trying to compile in Visual Studio 2010, but I don't ...
Verhogen's user avatar
  • 28.4k