-
Notifications
You must be signed in to change notification settings - Fork 108
fpm not preprocessing main.f90 with --flag -cpp
#791
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
Comments
It is passing the -cpp flag. It is the fact that when scanning the code for module dependencies it looks for USE statements unconditionally. It has actually not gotten to the compilation. The scan for USE does not know anything about cpp directives. So it is still a problem, but not quite what you describe. If you had something not being parsed for by fpm itself in the #if/#endif region it would work, for example. So #if... works in most cases that are not conditionally selecting a line being scanned for, like USE and INCLUDE statements would be for fpm(1) to automatically determine dependencies. It would require preprocessing all the input files and only scanning the files afterward to avoid this problem robustly; and the predefined variables the compiler users are not the same in all cases as those used by a straight call to the preprocessor, which would be a harder issue to hit, but also a problem. Not an elegant solution, but perhaps if a # is found in a file a missing file could be ignored or only be a warning; which except in the rare case where a file starts with a # character that is a continuation of the previous line this would help with cpp (but not all preprocessors, which do not all start directives with a # in column 1). If the module does not exist because it is external you are in luck. The USE statement will be ignored
then it is assumed the "nonexistent" module is not built by your package, and you want to have that line Another bug is that only "use " and "use::" are looked for, so if you use "use,non-intrinsic:: nonexistent" Same for using macros so the "use " string is not part of the line, which would also trick it. So hopefully, you really are only conditionally using an external module, and using the correct syntax in the fpm.toml file to indicate it is external correctly resolves the problem. Preprocessing all the files and putting the output files into the build/ directory would be a big change and would require careful consideration of how the compilers search for include files so I do not think that change would be coming any time soon. |
@urbanjost when you wrote "fpm.module," was that a typographical error? If so, then I think your suggested workaround will work for us because the dependency in question is not built by our project so we'll try putting |
Yes. should have been "fpm.toml". I cleaned up the original post a bit; I was composing this while it was being closed and did not realize it showed up. I think the discussion linked to above when this was marked as a duplicate basically says to do the same thing. |
Description
Using
fpm build --flag -cpp
to compile a simpleapp/main.f90
containing a C preprocessor directive fails:Compiling with
gfortran -cpp main.f90
works.Expected Behaviour
I expect
--flag -cpp
to causefpm
to usegfortran -cpp
to compile.Version of fpm
0.6.0
Platform and Architecture
macOS/Intel
Additional Information
No response
The text was updated successfully, but these errors were encountered: