version(D_Version2)
Bill Baxter
dnewsgroup at billbaxter.com
Wed Mar 12 17:14:55 PDT 2008
Derek Parnell wrote:
> On Wed, 12 Mar 2008 17:56:49 +0900, Bill Baxter wrote:
>
>> I just resorted to this in something I was doing the other day:
>>
>> > gcc -C -E -xc file_in.d | sed -e "s/^#/#line/" > file.d
>> > dmd file.d
>
> I have no idea what that means.
>
> I don't use gcc and I run D in a Windows environment. I use Linux daily at
> the office because that's I develop software for (but not in C/C++) so I
> understand the 'sed' part is, but what's gcc doing?
It's what the others said.
gcc -E just runs the preprocessor
-C says to keep the comments instead of stripping them
-xc says to pretend the following file is C code despite the extension.
The preprocessor spits out line directives like
# 1 "somefile"
In D those are supposed to be
#line 1 "somefile"
So the sed thing makes that change. The regexp there is pretty dumb,
though. Really I guess you need a parser that can understand quoted
strings to do the job 100% properly. But it was enough for my case.
--bb
More information about the Digitalmars-d
mailing list