Use #if not defined with OR boolean logic in preprocessor directives


 
Thread Tools Search this Thread
Top Forums Programming Use #if not defined with OR boolean logic in preprocessor directives
# 1  
Old 03-15-2016
Use #if not defined with OR boolean logic in preprocessor directives

I am currently using Linux CentOS and programming in FORTRAN 90 using Portland 7.1 compiler.

I am able to set in the preprocessor directives a flag called TEST. when I go to use logic in my code i can write

Code:
#ifdef TEST
   execute something
#endif

Furthermore, if I want to negate the logic I can type:

Code:
#ifndef
   execute something
#endif

Now, if I want to add some boolean logic like AND, OR etc. I have to use slightly different syntax as follows:

Code:
#if defined TEST || defined NEWTEST
   execute something
#endif

This allows me to say if the Flag "TEST" or the flag "NEWTEST" is defined then do something. What I cannot seem to find is how to negate the logic such that it says: if the Flag "TEST" is NOT defined OR the flag NEWTEST is NOT defined...

The syntax I have tried to come up with does not appear to work. I am looking for something similar to the following:

Code:
#if not defined TEST && not defined NEWTEST
   execute something
#endif

Any ideas??

Last edited by prodigious8; 03-15-2016 at 01:57 PM.. Reason: OR will not be valid for the logic I want
# 2  
Old 03-15-2016
Try ! for a negation.
This User Gave Thanks to MadeInGermany For This Post:
# 3  
Old 03-17-2016
Go for multi-line statement
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

WHy do we need both append and output directives?

Hi, I was reviewing a shell script and I found this line: yum -y update >> >(/usr/bin/tee /var/log/file) I have tried removing the >> directive and all that will occur is that the file will be created--nothing gets put in the file. If I put back the >> directive it works. If I remove the... (3 Replies)
Discussion started by: mojoman
3 Replies

2. Programming

Preprocessor __FILE__ for Debugging

Hi, Just wondering if it is possible to trim the file path output by __FILE__ preprocessor in my debugging line. Let's say my main.cpp file is found in C:\User\MyName\SystemA\Mod1\SubMod2\Test\main.cpp for __FILE__, I just want the filename - main.cpp to be printed, instead of the entire... (2 Replies)
Discussion started by: tanlccc
2 Replies

3. Programming

enum and C preprocessor

Say I have a list of enumerations I wish to use to select a variable at compile-time: enum pins { PIN_A=1, PIN_B=7, PIN_C=6, } int VAR1, VAR2, VAR3, VAR4, VAR5, VAR6, VAR7; #define PIN_TO_VAR(NUM) VAR ## NUM int main(void) { PIN_TO_VAR(PIN_A)=32;... (2 Replies)
Discussion started by: Corona688
2 Replies

4. Shell Programming and Scripting

logic for executing defined seq in file and cmd in file

I have four files a,b,c,d which need to contain certain in the sequence a, b, c ,d , each file command which needs to be executed, what i m in need is that to executed file and cmd in the defined order and if any of the command FAIL or throw ERROR, it script shud come out... (3 Replies)
Discussion started by: tarunn.dubeyy
3 Replies

5. Programming

Preprocessor

Hi, Anyone please explain the functionality of ## in c. I didn't get the following preprocessor directives, # define LL(x) x ## LL # define LL(x) x ## i64 Thanks, Naga:cool: (1 Reply)
Discussion started by: Nagapandi
1 Replies

6. Cybersecurity

php_admin_* directives in a phpSuExec environment

Hello, Is there anyway to prevent users from modifying limits imposed by php.ini configuration in a phpSuExec configured PHP installation?? For example in server with PHP running in a module, I use php_admin_* directives: php_admin_value memory_limit 40M And users can't modify them... (0 Replies)
Discussion started by: Santi
0 Replies

7. Cybersecurity

ipfw directives and order of precidence...

Is there a general rule I can apply when examining/editing ipfw entries? Also, does each new entry have to have a unique rule number? And, I think I can write a script to block code red infected machines (though I'm not sure it would do more than slim down my web server error message log),... (0 Replies)
Discussion started by: [MA]Flying_Meat
0 Replies
Login or Register to Ask a Question