Questions tagged [ifdefine]

37 questions
188
votes
7 answers

C++ compiling on Windows and Linux: ifdef switch

I want to run some c++ code on Linux and Windows. There are some pieces of code that I want to include only for one operating system and not the other. Is there a standard #ifdef that once can use? Something like: #ifdef LINUX_KEY_WORD ...…
15
votes
6 answers

Apache .htaccess - applying basic authentication conditionally based on environment or hostname

My dev setup: Mac OSX 10.7.4 / Apache 2.2.21 / PHP 5.3.10 I wish to add conditional logic to my .htaccess files depending on dev vs live environment. for example i want to have authentication on the live server but not on the dev server. i have in…
Devin Emke
  • 169
  • 1
  • 1
  • 6
7
votes
3 answers

Why include direct.h or sys/stat.h conditionally based on _WIN32 or __linux__?

What will the following code do? Why is it used? #ifdef _WIN32 #include #elif defined __linux__ #include #endif
Bosnia
  • 303
  • 1
  • 3
  • 9
6
votes
2 answers

#ifdef #else #endif choose iOS sdk version and function?

I am buliding a dark themed iOS 6 and 7 app. I understand I can call [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; to make the iOS 7 status bar suit a dark color theme application. The problem is I am going to…
HYC
  • 59
  • 1
  • 1
  • 7
5
votes
3 answers

How to do conditional .htaccess password protect

I'm trying to password protect a specific url using a .htaccess. Different urls point to the same files but have different workings. I now need to password protect only one url. I'm trying to do this using setenvif but it doesn't seem to work. I…
Clooner
  • 141
  • 2
  • 9
4
votes
1 answer

#error inside of #define - Possible in C++ (generate error WHEN calling macro MyMacro IF some constant is not defined)?

I want to define the macro, that based on some condition (existence of #define INITED, not the parameter of the macro) will return value, or generate compiler's error, like: #error Not initialized! I've tried (for myIdea.h): #ifdef INITED …
PolGraphic
  • 2,941
  • 9
  • 39
  • 100
3
votes
4 answers

SetEnvIf HTTP_HOST not working

I can't get it work this part of .htaccess, the IfDefine never runs. What am I doing wrong, setenvif mod is enabled. RewriteBase / SetEnvIf HTTP_HOST ^localhost$ local RewriteBase /codeigniter-app/ SetEnvIf HTTP_HOST…
Alex
  • 7,089
  • 19
  • 74
  • 141
3
votes
5 answers

Using C X macros in combination with #ifdef

Assuming my code looks like in the following snippet: #ifdef COND1 extern int func1(void); #endif ... #ifdef CONDN extern int funcn(void); #endif my_struct funcs[] = { #ifdef COND1 {"func1 description", func1}, #endif ... #ifdef CONDN …
3
votes
2 answers

How to use a variable from a Makefile in #ifdef in C++ file

Makefile ifeq ($(wifiSim),1) WIFISIM :=1 endif all: test.cpp test.cpp : test.o ./a.out test.o : c++ test.cpp test.cpp #include using namespace std; int main() { #ifdef WIFISIM cout <<…
a2n3k7it
  • 55
  • 1
  • 6
3
votes
2 answers

Conditional Directory Index In Htaccess

This relates to the question in: conditional DirectoryIndex in .htaccess The answer states that the following should work: SetEnvIf Remote_Addr ^127\.0\.0\.0$ owner DirectoryIndex index.html
Lizard
  • 39,504
  • 36
  • 102
  • 164
3
votes
3 answers

How to #define based on iOS version?

I have a Constants.h file in my app, where I #define app-wide things for easy access later. I'm having a hard time, though, #defineing based on iOS version. Here's what I've tried: #ifdef __IPHONE_7_0 #define kHamburgerImage [UIImage…
Undo
  • 25,204
  • 37
  • 102
  • 124
2
votes
1 answer

Check is member in struct with C

I want to access to member in struct but check if this member exist #include int main() { struct MyStruct { int a;}; struct MyStruct temp ; temp.a=3; return 0; } Is there a way to check if member a is in struct m and if…
2
votes
2 answers

purpose of #ifdef before main() in program

What is the purpose of the #ifdef below? And why does it allow me to step through my program when debugging it (active solution configuration = debug) but not when the active solution configuration = release or when building the solution and the…
traggatmot
  • 1,201
  • 3
  • 22
  • 42
1
vote
1 answer

How to know the version of the C# using the preprocessor?

My project in Debug mode contains constructs that only supports C# 7.3. But in Release mode, the project should be built on C# 7.0 without specific code lines. I know about some standard preprocessor symbols like NET472 and NETSTANDARD2_0 but it…
groser
  • 215
  • 1
  • 8
1
vote
2 answers

Why directive not working (Apache 2.4)?

I'm trying to block a IP list generated by CustomLog using IfDefine to avoid log ip again, but it's not working. I changed CustomLog conditional and something bizarre behavior can be observed: RewriteMap blacklist…
Arthur Ronconi
  • 1,634
  • 18
  • 17
1
2 3