472,983 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

#include with <> or "" ?

I have a folder 'app' containing a file 'main.cpp' and a subfolder 'types'
(containing various header files). In main.cpp some header files from the
subdir 'types' are included like:

1)
#include<types/vector.h>
#include<types/matrix.h>

But I have to change them to

2)
#include "types/vector.h"
#include "types/matrix.h"

to make compilation work. I know that 1) worked earlier with the original
makefile but I don't have that anymore. How is it possible to make the code
compile with the version used in 1) again?

I am currently working in MS Visual Studio 2008 and it seems that makefiles
are generated automatically.
Aug 1 '08 #1
4 2081
In article <48***********************@news.sunsite.dk>, as***@asd.com
says...
I have a folder 'app' containing a file 'main.cpp' and a subfolder 'types'
(containing various header files). In main.cpp some header files from the
subdir 'types' are included like:

1)
#include<types/vector.h>
#include<types/matrix.h>

But I have to change them to

2)
#include "types/vector.h"
#include "types/matrix.h"

to make compilation work.
This is what you almost certainly _should_ do. To make it work with the
angle brackets, you have to lie to the compiler and tell it that the
current diretory (i.e. the parent of your 'types' directory) contains
"system" headers. That's typically done with the the '-I' compiler flag,
though that varies and isn't really topical here anyway.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Aug 1 '08 #2
saneman wrote:
I have a folder 'app' containing a file 'main.cpp' and a subfolder 'types'
(containing various header files). In main.cpp some header files from the
subdir 'types' are included like:

1)
#include<types/vector.h>
#include<types/matrix.h>

But I have to change them to

2)
#include "types/vector.h"
#include "types/matrix.h"

to make compilation work. I know that 1) worked earlier with the original
makefile but I don't have that anymore. How is it possible to make the code
compile with the version used in 1) again?

I am currently working in MS Visual Studio 2008 and it seems that makefiles
are generated automatically.
The difference in processing of the angle-bracket type inclusion
directives and the double-quote type is *implementation-defined*. It is
not specified in the language Standard how those are different and what
to do in the case like yours. Please post to the newsgroup that deals
with your compiler. IIRC, VC++ looks in the project directory for the
quoted type and in the "include" directories for the bracketed type, so
you might need to add your current directory to the "list of include
directories" (see /I compiler option).

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 1 '08 #3
In article <48***********************@news.sunsite.dk>,
saneman <as***@asd.comwrote:
>I have a folder 'app' containing a file 'main.cpp' and a subfolder 'types'
(containing various header files). In main.cpp some header files from the
subdir 'types' are included like:

1)
#include<types/vector.h>
#include<types/matrix.h>

But I have to change them to

2)
#include "types/vector.h"
#include "types/matrix.h"

to make compilation work. I know that 1) worked earlier with the original
makefile but I don't have that anymore. How is it possible to make the code
compile with the version used in 1) again?

I am currently working in MS Visual Studio 2008 and it seems that makefiles
are generated automatically.
The intention of <is to search for "system header files"
whereas the intention of "" is to search for "other headers".
The problem is that a lot of this is left to the implementation
and not dictated by the standard, and as such, it is not completely
specified and the can even cross over to the other form
(IOWs, putting a system header files within "" and as on).
In short, it's left up to the implementation to document.
So the answer to your question is compiler specific, however,
that said, chances are good that you can getting it working with
a -I option, though the argument is that you probably should
prefer form (2).
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE == http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Aug 1 '08 #4
On Aug 1, 4:44 pm, Victor Bazarov <v.Abaza...@comAcast.netwrote:
saneman wrote:
I have a folder 'app' containing a file 'main.cpp' and a
subfolder 'types' (containing various header files). In
main.cpp some header files from the subdir 'types' are
included like:
1)
#include<types/vector.h>
#include<types/matrix.h>
But I have to change them to
2)
#include "types/vector.h"
#include "types/matrix.h"
to make compilation work. I know that 1) worked earlier with
the original makefile but I don't have that anymore. How is
it possible to make the code compile with the version used
in 1) again?
I am currently working in MS Visual Studio 2008 and it seems
that makefiles are generated automatically.
The difference in processing of the angle-bracket type
inclusion directives and the double-quote type is
*implementation-defined*.
In theory. In practice: includes in a <are searched first in
a list of directories that you provide (via -I or /I options,
depending on the compiler), then in some standard system places
(where the compiler is installed, then /usr/include under most
Unix; under Windows, at least with VC++, I think the contents of
the environement variable INCLUDE). An include "" first
searches in the directory where the file containing the include
was situated, and then acts exactly like an include <>.

Some compilers have additional options to modify this somewhat
(e.g. adding a directory which is only used by include ""), but
I've yet to find a compiler which didn't support the above.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Aug 1 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Dr Duck | last post by:
GDay all, Something seems odd to me.... I wrote a simple C# function public void bind(ref object a, ref object b, bool atob) { if(atob) b = a; else
8
by: active | last post by:
I use quickwatch on (astrThisOne <> "") and it reports: False as it should because astrThisOne reports: "" Yet If (astrThisOne <> "") Then executes the Then clause
12
by: Pablo Suarez | last post by:
When I code #include "myheader.h" then this header file is searched in the current directory. But where does the compiler search the header file when I write #include <myheader.h>
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.