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

Line directives after macro expansion #26

Open
jan-christiansen opened this issue Dec 2, 2024 · 1 comment
Open

Line directives after macro expansion #26

jan-christiansen opened this issue Dec 2, 2024 · 1 comment

Comments

@jan-christiansen
Copy link

I have the following Haskell file that contains a CPP macro.

#define FOO( x, y ) x ++ y

foo =
  FOO("a",
       "b"
       ++ "c")

bar = 1

When I call cpphs on this file, I get the following result.

#line 1 "Test.hs"


foo =
  "a" ++ "b"
       ++ "c"

bar = 1

The line directive states that the line that is following the directive is line 1 of Test.hs. Therefore, foo is still positioned at line 3 while bar is now positioned at line 7, while it has been in line 8 in the original file.

Does somebody know whether this behavior is intentional? I would have expected that cpphs inserts a line directive when a macro is expanded in order to fix the positions of the subsequent definitions. For example, clang and gcc yield the following output.

# 1 "<stdin>"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 417 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "<stdin>" 2


foo =
   "a" ++ 
      
# 4 "<stdin>"
  "b"
        
# 4 "<stdin>"
  ++ "c"



bar = 1

That is, there is a line marker that assigns line 8 to bar.

Does somebody know whether this is some kind of missing feature in cpphs or if there is some other reason for the behavior? Did I miss some other option to cpphs that would fix this problem?

@jan-christiansen
Copy link
Author

I have created a pull request #27 if this is of any interest.

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

1 participant