#including your #include.... 
Author Message
 #including your #include....

Thanks for listening.

I made a small change to my current project the other day,
and when I went to compile, the hard drive just sat
there churning away. I stopped it after a couple of minutes
(usually takes about 10 seconds), and I discovered that I
had a #include with the file of the same name, i.e.

        in file blah.h          #include "blah.h"

 Shouldn't the compiler pick this up?

 zuf.

--

[ Robotics & Digital Technology,  Monash University                
[ Melbourne, Victoria,            AUSTRALIA
[



Fri, 08 Mar 1996 14:44:57 GMT  
 #including your #include....

Quote:
>Thanks for listening.

>I made a small change to my current project the other day,
>and when I went to compile, the hard drive just sat
>there churning away. I stopped it after a couple of minutes
>(usually takes about 10 seconds), and I discovered that I
>had a #include with the file of the same name, i.e.

>    in file blah.h          #include "blah.h"

No it wouldn't (at least not a ANSI-C compiler).  One way to protect
against this would be have a ifndef/define at the start of the header file..

/* blah.h */

#ifndef BLAH_INCLUDE
#define BLAH_INCLUDE

#include "blah.h"

/* rest of code to go into header */

#endif  /* BLAH_INCLUDE */

--
+ Michael Neylon - UM ChE Grad (BS UTo) // How do YOU spell 'Potato'? +
+--Summer Intern NASA Lewis------------//-----------------------------+

+      'It is not I who is crazy... \X/  It is I who is MAD!' - R&S   +



Fri, 08 Mar 1996 19:00:34 GMT  
 #including your #include....


Quote:
> Thanks for listening.

> I made a small change to my current project the other day,
> and when I went to compile, the hard drive just sat
> there churning away. I stopped it after a couple of minutes
> (usually takes about 10 seconds), and I discovered that I
> had a #include with the file of the same name, i.e.

>    in file blah.h          #include "blah.h"

>  Shouldn't the compiler pick this up?

>  zuf.

Not really.  Perhaps after a given recursion level, the compiler could say
something like - oops... #includes nested too deeply.  The reason I say this
is that I actually _USE_ recursive self-inclusion to force pre-declaration of
data structures so that on the second/third/whatever #include pass, I can
create an alignment filler at the bottom of the _real_ structure definition
that causes the whole structure to occupy a natural alignment boundary.

I realize that this is totally {*filter*}, but there seems to be no other
immediately apparent way to accomplish that goal.

David G. North, CCP

"The squeaking wheel doesn't always get the grease. Sometimes it gets replaced."



Sat, 09 Mar 1996 15:57:44 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Missing includes in /usr/include/linux/*.h and /usr/include/asm.h

2. include file of includes

3. source for included included files

4. How to include CRecordset without including MFC?

5. Why won't a include file get included some times and not other

6. #include "foo" vs #include <foo>

7. include "file" or include <file>?

8. #include "foo" vs #include <foo>

9. HP aCC compiler #include<> and #include""

10. Difference between #include "" and #include <>?

11. #include "filename.h" does not mean "include user file"

12. #include "stdafx.h" needs to appear before #include <fstream>?

 

 
Powered by phpBB® Forum Software