468,512 Members | 1,341 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

including header files

hello friends,

This is Radha. I have a querry about one of the concepts of c++ like includeing header files in c/c++ program . When i try to inlclude header files for for implementing a program on message queue..

In that when i try to include one of the header files called "SYS\TYPES.H"
it is showing error like "UNABLE TO INCLUDE SYS\TYPES.H" but it is showing that header file in list and even it is present in the directory in the path which i have gave in the directory settings..

please any one help me out to on this as soon as possible please please please.........


Regards,
Radha.
Apr 6 '08 #1
7 3459
Laharl
849 Expert 512MB
You've got the wrong slash. Use / instead of \.
Apr 6 '08 #2
weaknessforcats
9,207 Expert Mod 8TB
Your compiler's preprocessor looks for header files based on pre-defined paths.

When you #include <aheader.h>, the path t this header must be already defined. Your compiler's documentation will tell how to set this path. Typically, you cn have many paths set and each will be searched for the header.

When you #include "aheader.h", the header is presumed to be in the present working directory (PWD) and if not there, the search reverts the #include <aheader.h>.

I would not use relative paths
Apr 6 '08 #3
Laharl
849 Expert 512MB
<sys/types> is a Unix header that contains gcc's POSIX types. While it is a relative filepath, the <> notation under Linux goes to /usr/include (or the equivalent, depending on distro) and this file is /usr/include/sys/types.h, so the relative path is necessary by the default gcc/g++ settings, anyway.
Apr 6 '08 #4
weaknessforcats
9,207 Expert Mod 8TB
I see. Obviously, my Windows are showing again.
Apr 6 '08 #5
Banfa
9,056 Expert Mod 8TB
Actually in general a path like

#include <sys\types.h>

will work by adding the relative path to the each path in the defined set of include paths to search, it is not uncommon on any platform to have a sys include directory from the normal platform include directory that contains platform system headers, while the platform directory contains the C and/or C++ standard library headers (and other junk sometimes (take a look at the Windows include directory)).

e.g.

C:\MyPlatform\include <-- standard library headers here
C:\MyPlatform\include\sys <-- platform system headers here

Even Microsoft follows this a little putting (some of?) the POSIX headers into the sys directory

e.g.

C:\Program Files\Microsoft Visual Studio 8\VC\include\sys\types.h


Normally the sys directory is never explicitly put into the include path and has to be accessed via a relative path.
Apr 7 '08 #6
weaknessforcats
9,207 Expert Mod 8TB
Don't forget that with Windows you have to double the backslashes:
Expand|Select|Wrap|Line Numbers
  1. C:\\Program Files\\Microsoft Visual Studio 8\\VC\\include\\sys\\types.h
  2.  
Apr 7 '08 #7
Banfa
9,056 Expert Mod 8TB
Don't forget that with Windows you have to double the backslashes:
Expand|Select|Wrap|Line Numbers
  1. C:\\Program Files\\Microsoft Visual Studio 8\\VC\\include\\sys\\types.h
  2.  
Not in an include statement only in a C type string.
Apr 7 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by cppaddict | last post: by
3 posts views Thread by Miguel | last post: by
1 post views Thread by Ben | last post: by
8 posts views Thread by nrhayyal | last post: by
31 posts views Thread by Joseph Wakeling | last post: by
6 posts views Thread by Al-Burak | last post: by
2 posts views Thread by shruti | last post: by
3 posts views Thread by KIRAN | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.