Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to emulate -traditional-cpp behavior? #84

Closed
mathomp4 opened this issue Nov 27, 2023 · 2 comments
Closed

Possible to emulate -traditional-cpp behavior? #84

mathomp4 opened this issue Nov 27, 2023 · 2 comments

Comments

@mathomp4
Copy link

When Ford recently moved to use pcpp as its default preprocessor, we found our docs failed to build during the preprocessing step (see Fortran-FOSS-Programmers/ford#600).

The issue seems to be that we sort of rely on -traditional-cpp behavior of GNU cpp; I'm guessing because we are preprocessing Fortran and not C.

For example, given this Fortran code:

#  define __QUOTE(x) x
#  define __PROC(x) __QUOTE(a)__QUOTE(x)

__PROC(b)

with GNU cpp and -traditional-cpp:

❯ cpp-12 -traditional-cpp test.F90
# 0 "test.F90"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "test.F90"



ab

and ab is what we'd expect and we get the same behavior with NAG's fpp preprocessor.

But with pcpp:

❯ pcpp test.F90
#line 4 "test.F90"
a b

there is an extra space and so things go wonky. Similar for cpp without the flag:

❯ cpp-12 test.F90
# 0 "test.F90"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "test.F90"



a b

I guess my question is: is there a way to emulate the -traditional-cpp behavior with pcpp? Or is that sort of...antithetical to pcpp's purpose?

Note: I can't remember why, but there is a portability reason this layer doesn't use ## concatenation or other things, but I'd have to consult the dev. What we've found is this is our most

@ned14
Copy link
Owner

ned14 commented Nov 27, 2023

pcpp matches the ISO C preprocessor here (https://godbolt.org/z/qdr7Ka8Yj), so I'm not especially warm to special opt out flags, as then people would want more so they can have pcpp match MSVC's broken preprocessor and other such carve outs.

You could fork pcpp?

@mathomp4
Copy link
Author

pcpp matches the ISO C preprocessor here (https://godbolt.org/z/qdr7Ka8Yj), so I'm not especially warm to special opt out flags, as then people would want more so they can have pcpp match MSVC's broken preprocessor and other such carve outs.

You could fork pcpp?

Ehhh. Not that important as Ford (via @ZedThree) provides us a workaround. I just didn't know if one of the many options pcpp has emulated it. If it doesn't, it doesn't.

My guess is the "right" solution is to wait a few years until Fortran 202Y is out which I believe will introduce a preprocessor into the Fortran Standard. Then at that point, someone ambitious can make pfpp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants