Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #17684 > unrolled thread
| Started by | ashu <ashutosh.ghildiyal@gmail.com> |
|---|---|
| First post | 2012-02-20 09:57 -0800 |
| Last post | 2012-02-20 14:52 -0500 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.c
Conditional compilation ashu <ashutosh.ghildiyal@gmail.com> - 2012-02-20 09:57 -0800
Re: Conditional compilation Ian Collins <ian-news@hotmail.com> - 2012-02-21 07:42 +1300
Re: Conditional compilation Shao Miller <sha0.miller@gmail.com> - 2012-02-20 14:52 -0500
Re: Conditional compilation Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-02-20 14:52 -0500
| From | ashu <ashutosh.ghildiyal@gmail.com> |
|---|---|
| Date | 2012-02-20 09:57 -0800 |
| Subject | Conditional compilation |
| Message-ID | <d04b882b-429a-4167-adbb-99a17cd3ac9d@i18g2000yqf.googlegroups.com> |
Hi all, I have a very trivial problem with conditional compilation. I have a header file called wrapper.h which is like the global header file for my project. In this header file I want to define a conditional compilation tag called DEBUG. This file wrapper.h includes several other files called demo1.h demo2.c etc. as follows. /***** wrapper.h****/ #define DEBUG #include demo1.h #include demo2.h ....... /*****end of wrapper.h**/ Now if I try to use the conditional compilation flag DEBUG in any of these included files, like demo1.h or demo2.h I get an error and the compilation fails. /**** demo1.h ***/ # if defined (DEBUG) #define BASE_ADDRESS #endif /***end of demo1.h***/ Can someone help me and point to me my mistake ? The compilation error is BASE_ADDRESS undeclared and I am using GCC. regards /***end of demo1.h**/
[toc] | [next] | [standalone]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Date | 2012-02-21 07:42 +1300 |
| Message-ID | <9qfig1F22vU1@mid.individual.net> |
| In reply to | #17684 |
On 02/21/12 06:57 AM, ashu wrote: > Hi all, I have a very trivial problem with conditional compilation. I > have a header file called > wrapper.h which is like the global header file for my project. In this > header file I want to define a conditional compilation tag called > DEBUG. This file wrapper.h includes several other files called demo1.h > demo2.c etc. as follows. > > /***** wrapper.h****/ > > #define DEBUG > #include demo1.h > #include demo2.h > ........ > > /*****end of wrapper.h**/ > > Now if I try to use the conditional compilation flag DEBUG in any of > these included files, like demo1.h or demo2.h I get an error and the > compilation fails. > > /**** demo1.h ***/ > # if defined (DEBUG) > #define BASE_ADDRESS > #endif > > /***end of demo1.h***/ > > Can someone help me and point to me my mistake ? The compilation error > is BASE_ADDRESS undeclared and I am using GCC. > > regards > > /***end of demo1.h**/ Showing the actual error and the code where it occurs would help. -- Ian Collins
[toc] | [prev] | [next] | [standalone]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Date | 2012-02-20 14:52 -0500 |
| Message-ID | <jhu84f$bik$1@dont-email.me> |
| In reply to | #17684 |
On 2/20/2012 12:57, ashu wrote: > > Now if I try to use the conditional compilation flag DEBUG in any of > these included files, like demo1.h or demo2.h I get an error and the > compilation fails. > > /**** demo1.h ***/ > # if defined (DEBUG) > #define BASE_ADDRESS > #endif > > /***end of demo1.h***/ > > Can someone help me and point to me my mistake ? The compilation error > is BASE_ADDRESS undeclared and I am using GCC. > > regards > > /***end of demo1.h**/ > It looks to me like you are forgetting to provide an alternative and are using 'BASE_ADDRESS' somewhere in the code regardless of whether or not 'DEBUG' is defined. #if defined (DEBUG) # define BASE_ADDRESS value_when_debugging_is_enabled #else # define BASE_ADDRESS value_when_debugging_is_disabled #endif
[toc] | [prev] | [next] | [standalone]
| From | Eric Sosman <esosman@ieee-dot-org.invalid> |
|---|---|
| Date | 2012-02-20 14:52 -0500 |
| Message-ID | <jhu8a2$cpe$1@dont-email.me> |
| In reply to | #17684 |
On 2/20/2012 12:57 PM, ashu wrote:
> Hi all, I have a very trivial problem with conditional compilation.
Since you haven't solved it, how do you know it's trivial?
> /***** wrapper.h****/
>
> #define DEBUG
> #include demo1.h
> #include demo2.h
Missing some punctuation here, probably " marks.
> /*****end of wrapper.h**/
>
> Now if I try to use the conditional compilation flag DEBUG in any of
> these included files, like demo1.h or demo2.h I get an error and the
> compilation fails.
>
> /**** demo1.h ***/
> # if defined (DEBUG)
> #define BASE_ADDRESS
> #endif
>
> /***end of demo1.h***/
>
> Can someone help me and point to me my mistake ? The compilation error
> is BASE_ADDRESS undeclared and I am using GCC.
Please post a short and *complete* example of your problem.
What you've provided above is (1) insufficient to support a
diagnosis, and (2) quite clearly not the code the compiler saw.
Good thing the problem's trivial, right?
--
Eric Sosman
esosman@ieee-dot-org.invalid
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web