473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3730
Laharl
849 Expert 512MB
You've got the wrong slash. Use / instead of \.
Apr 6 '08 #2
weaknessforcats
9,208 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,208 Expert Mod 8TB
I see. Obviously, my Windows are showing again.
Apr 6 '08 #5
Banfa
9,065 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,208 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,065 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

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

Similar topics

11
by: cppaddict | last post by:
Say that your CustomClass.h header files requires #include <string> Now say that your CustomClass.cpp file also requires string. Is it good form to repeat the <string> include to make the...
3
by: Miguel | last post by:
I have a header file that I want to share among various files, and I use: #ifndef UTIL_H_ #define UTIL_H_ file contents #endif
1
by: Ben | last post by:
Hi guys, this *should* be a simple problem, but I've never really got my head around it. I'm hoping somebody on this message board could help me out? I don't really have any experience with VS.NET,...
8
by: nrhayyal | last post by:
Hi c++ Gurus, Need your blessing. while testing few aspects with respect to header file inclusions, i observed few things which i would like to share with you. i have a file sqlca.h in which a...
31
by: Joseph Wakeling | last post by:
Hello all, I'm writing some programs that will be using modules from the GNU Scientific Library (GSL). Include commands within the GSL modules have commands such as, #include...
6
by: Al-Burak | last post by:
I have a class which only purpose is to provide services to a variety of classes in other files. The 'manipulator' class is aware of the other classes only because the header files have been...
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
18
by: sam_cit | last post by:
Hi Everyone, int main() { printf("not included stdio.h"); } Yes, i haven't included stdio.h and my compiler would generate a warning and would assume that it would return a int, my question...
8
by: nguillot | last post by:
Hello. If I have the following classes: class B {}; typedef B tB; if A is: class A
3
by: KIRAN | last post by:
Hello all, My question is about the way of including header files(*.h) in source files (*.c) I have three folders, -build ( for project makefiles) -include ( for *.h files) -src (for *.c...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.