Sponsored Content
Top Forums Programming Preprocessor __FILE__ for Debugging Post 302557389 by tanlccc on Wednesday 21st of September 2011 05:26:30 AM
Old 09-21-2011
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 path + filename.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regarding Debugging

Hi, If we want to debug a shell script, then set -vx has to be included in the begining of the script. Just i want to know what purpose -vx is used. Thanks in advace Sarwan (2 Replies)
Discussion started by: sarwan
2 Replies

2. Solaris

debugging

when I tried to debug my application i got the following. gdb -v GNU gdb 6.6 file is in C and Xmotiff Languages (gdb) attach 25499 Attaching to process 25499 Retry #1: Retry #2: Retry #3: Retry #4: 0xfea40b68 in ?? () (gdb) where #0 0xfea40b68 in ?? () (0 Replies)
Discussion started by: satish@123
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. Programming

Need some help in debugging the C-Progam.

Hi i want to debug the C program with GDB debugger. I want to debug the program by line by line. I want to debug program like as we debug the program in Turbo-C using the F8. Can any one help me? I know i have to use single stepping. But i don't know how to use it. Any help can be appreciated..... (5 Replies)
Discussion started by: ps_sach
5 Replies

5. Shell Programming and Scripting

Fixer Debugging

hi all, would you please help me correcting and debugging this script: fx-permiss.sh which accepts a list of users as argument resiting those files permissions: say our directory structure: /home/erzal/file /home/erzal/dire /home/erzal/share /home/erzal/share/file /home/erzal/share/dire 1-... (1 Reply)
Discussion started by: erzal
1 Replies

6. Homework & Coursework Questions

Fixer Debugging

School:Syrian Virtual University - Bachelor in Information Technology - Tutor: A.Issa - course: S10-iti320 hi all, would you please help me correcting and debugging this script: fx-permiss.sh which accepts a list of users as argument resiting those files permissions: say our directory... (0 Replies)
Discussion started by: erzal
0 Replies

7. UNIX for Dummies Questions & Answers

blcr debugging

hey, can any one please tell me how can i debug blcr?? actually i have checkpointd a client using blcr and i want to check out what actually happens when we checkpoint any program. so i want to see what happen when we type $cr_checkpoint pid i mean i want to debug when i enter this... (0 Replies)
Discussion started by: pratibha
0 Replies

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

9. Programming

c++ debugging

hey i have a problem with a switch case in program and the debugger is messy has hell ( we use normal VI and gdb in our schoool to make it more diffiacult) any way i have a problom where for some unknown reason the debugger just skips a switch statment as if it wasent even there the rest... (2 Replies)
Discussion started by: gotenxds
2 Replies

10. Programming

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 #ifdef TEST execute something #endif Furthermore, if I want to negate the... (2 Replies)
Discussion started by: prodigious8
2 Replies
cpp(1)							      General Commands Manual							    cpp(1)

Name
       cpp - the C language preprocessor

Syntax
       /lib/cpp [ option ...  ] [ ifile [ ofile ] ]

Description
       The  command is the C language preprocessor which is invoked as the first pass of any C compilation using the command.  Thus, the output of
       is designed to be in a form acceptable as input to the next pass of the C compiler.

       The preferred way to invoke however, is through the command.  See for a general macro processor.

Arguments
       The command optionally accepts two file names as arguments.  The ifile and ofile are, respectively, the input and output for the preproces-
       sor.  They default to standard input and standard output if no argument is supplied.

Options
       -B		   Strips C++-style comments (begin with // and end with newline).

       -C		   Passes along all comments, except those found on directive lines.  By default, strips C-style comments.

       -M		   Generates dependency lists suitable for use with instead of the normal output.

       -P		   Preprocesses the input without producing the line control information used by the next pass of the C compiler.

       -R		   Permits recursion when a macro is expanded.

       -Uname		   Removes  any  initial  definition of name, where name is a reserved symbol that is predefined by the preprocessor.  The
			   symbols predefined by this implementation are bsd4_2, ultrix, unix, mips, host_mips, and MIPSEL.

       -Dname
       -Dname=def	   Defines name as if by a #define directive.  If no =def is given, name is defined as 1.  The -D option has lower  prece-
			   dence  than	the  -U  option.   That is, if the same name is used in both a -U option and a -D option, the name remains
			   undefined regardless of the order of the options.

       -Idir		   Changes the algorithm for searching for #include files whose names do not begin with a slash (  /  )  to  look  in  dir
			   before looking in the directories on the standard list.  Thus, #include files whose names are enclosed in quotes ( "" )
			   will be searched for first in the directory of the file with the  #include  line,  then  in	directories  named  in	-I
			   options,  and, finally, in directories on a standard list.  For #include files whose names are enclosed in angle brack-
			   ets (<>), the directory of the file with the #include line is not searched.

Directives
       All directives start with lines that begin with a pound sign (#).  Any number of blanks and tabs are allowed between the  pound	signs  and
       the directive.  The following is a list of the directives:

       #define name(arg, ...,arg ) token-string
			   Replaces  subsequent instances of name and the following set of tokens that is enclosed in parentheses by token-string.
			   Each occurrence of an arg in the token-string is replaced by the corresponding set of  tokens  in  the  comma-separated
			   list.   Note  that  spaces  between	name and the left parenthesis (() are not allowed.  When a macro with arguments is
			   expanded, the arguments are placed unchanged into the expanded token-string .  After the entire token-string  has  been
			   expanded, re-starts its scan for names to expand at the beginning of the newly created token-string.

       #undef name	   Causes the definition of name (if any) to be forgotten.

       #include "filename"
       #include <filename> Includes  the  contents  of filename , which will then be run through When the <filename> notation is used, filename is
			   searched for in the standard places.  See the -I option above for more detail.

       #line integer-constant "filename"
			   Causes to generate line control information for the next pass of the C compiler.  Integer-constant is the  line  number
			   of  the  next  line	and filename is the file that it comes from.  If "filename" is not given, the current file name is
			   unchanged.

       #endif
			   Ends a section of lines begun by a test directive (#if, #ifdef, or #ifndef).  Each test directive must have a  matching
			   #endif.

       #ifdef name	   Defines  text  that will appear in the output if name has been the subject of a previous #define without being the sub-
			   ject of an intervening #undef.

       #ifndef name	   Defines text that will not appear in the output if name has been the subject of a previous #define  without	being  the
			   subject of an intervening #undef.

       #if constant-expression
			   Defines text that will appear in the output if constant-expression is not zero.  All binary non-assignment C operators,
			   which include the ?: , en dash (-), exclamation mark (!), and tilde (~) are legal in constant-expression.   The  prece-
			   dence  of the operators is the same as defined by the C language.  There is also a unary operator defined, which can be
			   used in constant-expression in these two forms: defined ( name ) or defined name.  This allows the  utility	of  #ifdef
			   and	#ifndef  in a #if directive.  Only these operators, integer constants, and names which are known by should be used
			   in constant-expression.  In particular, the sizeof operator is not available.

       #else		   Reverses the notion of the test directive which matches this directive.  So	if  lines  prior  to  this  directive  are
			   ignored, the following lines will appear in the output.  The reverse is also true.

       #elif constant-expression
			   Defines  text  that	will  appear  in  the  output if the preceding test directive and all intervening #elif directives
			   equalled zero and the constant-expression did not equal zero.  The rules for constant-expression are the  same  as  for
			   the #if directive.

       The test directives and the possible #else and #elif directives can be nested.

       In addition to these directives, the System V #ident directive is recognized and ignored.

       Two  special  names  are understood by __LINE__ is defined as the current line number (as a decimal integer) and __FILE__ is defined as the
       current file name (as a C string).  They can be used in any situations where you would use other defined names, including in macros.

Diagnostics
       The error messages produced by are self-explanatory.  The line number and filename where the error occurred  are  printed  along  with  the
       diagnostic.

Files
       /usr/include   standard directory for #include files

See Also
       cc(1), m4(1)

								       RISC								    cpp(1)
All times are GMT -4. The time now is 10:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy