How can I use directory in preprecessor command ifndef
EXAMPLE
#ifndef DIR/HEADERFILE_H
#include "dir/headerfile.h"
#endif
How can I use directory in preprecessor command ifndef
EXAMPLE
#ifndef DIR/HEADERFILE_H
#include "dir/headerfile.h"
#endif
As explained in this question, only alphanumeric characters and underscores (a-z, A-Z, 0-9, and _) are allowed for macro and constants names. You can define your own constant replacing / with _:
#ifndef DIR_HEADERFILE_H
To answer the specicif question, you cannot use a directory in a preprocessor command like #ifndef.
The include guards in the header file often take the form
#ifndef DIRECTORY_HEADERFILE_INCLUDED
#define DIRECTORY_HEADERFILE_INCLUDED
//.... contents
#endif
To include the header, then simple use
#include "dir/headerfile.h"
A long while ago some people suugested a double include guard, or redundant include guard, wherein you checked before the #include line to speed things up, as mentioned in this question. The c2 wiki has some further information esp.
"Good compilers make this idiom unnecessary. "
In either case the tendacny is to use _ instead of /, to form a valid macro.