I have to write a C preprocess, and it's hard :-) 
Author Message
 I have to write a C preprocess, and it's hard :-)

Hi,

I have to write a C preprocess and I'm finding it a bit tough with the
logic.
I have to write it as it's going to be put in some commercial software(maybe
not if there is source code I can use without problems??).

Now we use VC++ to parse some config files before we give them to a
customer.
Well we want the config files to be parsed at the customer site, this gives
us a bit better support.

So last week I started, thought I did really well, worked with our config
files. With the right defines the files looked the same, so far so good I
thought.
Then my boss starts getting really into this idea about having a parse and
now we can do so much more with these config files.
Well I didn't write a complete preprocess I just did enough for our config
files.
Things like this, no chance :-(
#define APPPATH C:\\program
#define TTT APPPATH##\config\bitmaps\logo.bmp
#define VVV(X) # X
#define ZZZ(X) VVV(X)
#if !defined(COMPANY)
blah
#endif

These are simple examples, but they screw-up because I didn't think about
this stuff.
So any help how to write a good preprocess??
It's the logic/defenation what is allowed I'm more interested in.

Thanks
Jippie



Tue, 23 Nov 2004 05:07:09 GMT  
 I have to write a C preprocess, and it's hard :-)

Quote:

> Hi,

> I have to write a C preprocess and I'm finding it a bit tough with the
> logic.
> I have to write it as it's going to be put in some commercial
software(maybe
> not if there is source code I can use without problems??).

> Now we use VC++ to parse some config files before we give them to a
> customer.
> Well we want the config files to be parsed at the customer site, this
gives
> us a bit better support.

> So last week I started, thought I did really well, worked with our config
> files. With the right defines the files looked the same, so far so good I
> thought.
> Then my boss starts getting really into this idea about having a parse and
> now we can do so much more with these config files.
> Well I didn't write a complete preprocess I just did enough for our config
> files.
> Things like this, no chance :-(
> #define APPPATH C:\\program
> #define TTT APPPATH##\config\bitmaps\logo.bmp
> #define VVV(X) # X
> #define ZZZ(X) VVV(X)
> #if !defined(COMPANY)
> blah
> #endif

> These are simple examples, but they screw-up because I didn't think about
> this stuff.
> So any help how to write a good preprocess??
> It's the logic/defenation what is allowed I'm more interested in.

> Thanks
> Jippie

Here are a few tidbits, ideas, and things to think about:
1) Ask yourself, "What do I want out of this?" Is your goal to be able to
preprocess your config file so that others may use it, or just to obfuscate
the config file?
2) In the Unix, Linux, MS-DOS, and Windows worlds, use forward slashes in
path names, and no absolute paths. What happens when you want to compile
this in drive D:?

I'm sure my listmates have more ideas....

Gregory Pietsch



Tue, 23 Nov 2004 06:27:57 GMT  
 I have to write a C preprocess, and it's hard :-)
Is there a necessity that you need to write the preprocessing in C.I
would think given the timeframe its easy writing the preprocessing in
scripting language like PERL.They give so many advantages and its
really flexible to write such applications in Perl.You may argue that
a C compiler does it? Yes agreed but that would take a lot of time.I
was in the process of doing the same thing that you started , and
after few kilo-lines of code i had to discontinue , to do the same
thing in Perl and guess what i could finish it faster than I took to
write in C.But all this depends on if you can use the scripting
language on the client place.I can give away the code I had written
right away but as its a s/w that I had written for my firm i cannot
give it.Anyway Best of Luck.

Badhri

Quote:



> > Hi,

> > I have to write a C preprocess and I'm finding it a bit tough with the
> > logic.
> > I have to write it as it's going to be put in some commercial
>  software(maybe
> > not if there is source code I can use without problems??).

> > Now we use VC++ to parse some config files before we give them to a
> > customer.
> > Well we want the config files to be parsed at the customer site, this
>  gives
> > us a bit better support.

> > So last week I started, thought I did really well, worked with our config
> > files. With the right defines the files looked the same, so far so good I
> > thought.
> > Then my boss starts getting really into this idea about having a parse and
> > now we can do so much more with these config files.
> > Well I didn't write a complete preprocess I just did enough for our config
> > files.
> > Things like this, no chance :-(
> > #define APPPATH C:\\program
> > #define TTT APPPATH##\config\bitmaps\logo.bmp
> > #define VVV(X) # X
> > #define ZZZ(X) VVV(X)
> > #if !defined(COMPANY)
> > blah
> > #endif

> > These are simple examples, but they screw-up because I didn't think about
> > this stuff.
> > So any help how to write a good preprocess??
> > It's the logic/defenation what is allowed I'm more interested in.

> > Thanks
> > Jippie

> Here are a few tidbits, ideas, and things to think about:
> 1) Ask yourself, "What do I want out of this?" Is your goal to be able to
> preprocess your config file so that others may use it, or just to obfuscate
> the config file?
> 2) In the Unix, Linux, MS-DOS, and Windows worlds, use forward slashes in
> path names, and no absolute paths. What happens when you want to compile
> this in drive D:?

> I'm sure my listmates have more ideas....

> Gregory Pietsch



Tue, 23 Nov 2004 13:50:10 GMT  
 I have to write a C preprocess, and it's hard :-)

Quote:

>Hi,

>I have to write a C preprocess and I'm finding it a bit tough with the
>logic.

Do you have to *write* it, or do you just need a c-preprocessor?
Most c-compilers have the -E option to isolate the preprocessing
stage. Now just fork it.

(Admittedly this may be easier if it can be used as a filter, but e.g.
gcc lacks this possibility. Professional c-compilers of commercial
vendors -- visual c comes to mind -- probably have better
facilities, but I didn't check this out. ;-) )

--
Groetjes Albert.
--
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
To suffer is the prerogative of the strong. The weak -- perish.



Sat, 04 Dec 2004 08:43:45 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. having hard time getting good SERVICE these days

2. Ok, I know it's stupid,but..[Preprocessing]

3. Newbie: separate big .cs file into small .cs files

4. 'Hard Problem' Update CRecordSet

5. 'Hard Question' Update Problem

6. Can't retrieve cookies in .cs file, but works in aspx page

7. Having problems incorporating pre-written code into my program

8. Having problems incorporating pre-written code into my program

9. CEdit::CharFromPos -- trying to write a bugfix, please help (having problems with tabs)

10. Having a problem in writing a service Application

11. Hard Real Time Applications really HARD to programme

12. The VC#'s hardest question

 

 
Powered by phpBB® Forum Software