Sponsored Content
Top Forums Programming Use #if not defined with OR boolean logic in preprocessor directives Post 302968865 by prodigious8 on Tuesday 15th of March 2016 10:42:47 AM
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
 

7 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

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

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

6. 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

7. 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
YACC(1) 						    BSD General Commands Manual 						   YACC(1)

NAME
yacc -- an LALR(1) parser generator SYNOPSIS
yacc [-dlrtvy] [-b file_prefix] [-o output_filename] [-p symbol_prefix] filename DESCRIPTION
The yacc utility reads the grammar specification in the file filename and generates an LR(1) parser for it. The parsers consist of a set of LALR(1) parsing tables and a driver routine written in the C programming language. The yacc utility normally writes the parse tables and the driver routine to the file y.tab.c. The following options are available: -b file_prefix Change the prefix prepended to the output file names to the string denoted by file_prefix. The default prefix is the character y. -d Cause the header file y.tab.h to be written. -l If the -l option is not specified, yacc will insert #line directives in the generated code. The #line directives let the C compiler relate errors in the generated code to the user's original code. If the -l option is specified, yacc will not insert the #line directives. Any #line directives specified by the user will be retained. -o output_filename Cause yacc to write the generated code to output_filename instead of the default file, y.tab.c. -p symbol_prefix Change the prefix prepended to yacc-generated symbols to the string denoted by symbol_prefix. The default prefix is the string yy. -r Cause yacc to produce separate files for code and tables. The code file is named y.code.c, and the tables file is named y.tab.c. -t Change the preprocessor directives generated by yacc so that debugging statements will be incorporated in the compiled code. -v Cause a human-readable description of the generated parser to be written to the file y.output. -y NOOP for bison compatibility. yacc is already designed to be POSIX yacc compatible. ENVIRONMENT
TMPDIR Name of directory where temporary files are to be created. TABLES
The names of the tables generated by this version of yacc are yylhs, yylen, yydefred, yydgoto, yysindex, yyrindex, yygindex, yytable, and yycheck. Two additional tables, yyname and yyrule, are created if YYDEBUG is defined and non-zero. FILES
y.code.c y.tab.c y.tab.h y.output /tmp/yacc.aXXXXXXXXXX /tmp/yacc.tXXXXXXXXXX /tmp/yacc.uXXXXXXXXXX DIAGNOSTICS
If there are rules that are never reduced, the number of such rules is reported on standard error. If there are any LALR(1) conflicts, the number of conflicts is reported on standard error. SEE ALSO
yyfix(1) STANDARDS
The yacc utility conforms to IEEE Std 1003.2 (``POSIX.2''). HISTORY
A yacc command appeared in PWB UNIX. BSD
May 24, 1993 BSD
All times are GMT -4. The time now is 12:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy