delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/16/16:15:04

Sender: "Rolf Campbell" <cp1v45 AT nortelnetworks DOT com>
Message-ID: <3768057F.55A3A47A@americasm01.nt.com>
Date: Wed, 16 Jun 1999 16:13:51 -0400
From: "Rolf Campbell" <cp1v45 AT nortelnetworks DOT com>
Organization: Nortel Networks
X-Mailer: Mozilla 4.6 [en] (X11; I; HP-UX B.10.20 9000/712)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: #define and lines
References: <199906161942 DOT VAA01399 AT acp3bf DOT physik DOT rwth-aachen DOT de>
Reply-To: djgpp AT delorie DOT com

Hans-Bernhard Broeker wrote:

> In article <3767F65C DOT B3E58FDC AT americasm01 DOT nt DOT com> you wrote:
> > Is there any way to write a #define who's expansion covers more than one
> > line?  I already know how to make the definition span-lines, but when
> > expanded, they are cramped on a single line.
>
> No way. OTOH, why would anyone care? C preprocessor output is not
> meant to be read by anything but the C compiler, so why bother about
> long lines instead of several short ones?

    I am actually using the C preprocessor to process html files.  I needed
to display fractions in html, and I didn't want to have to make hundreds of
gif's, so I found a kinda obsure way of doing it with table's inside tables,
but it is a lot to type each time, so I thought I could make a C-style macro
which would expand in html.  And I did and it works fine.  The only problem
is the code is hard to read (if that is a problem, and I'm not convinced
either way).  I was just wondering if there was a way around it.

> The only parts of the C programming language where a newline is
> required are preprocessing commands, anyway. With the preprocessor
> itself being a one-pass operation, you cannot generate preprocessor
> commands by macro-expansion, either, so there's no need for the
> preprocessor to be able to generate newlines.

    That's not entirely true.  You can use -DMAC=#define on a command-line to
make a macro that expands to a preprocessor directive.

--
     -Rolf Campbell (39)3-6318



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019