-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description
Compiling a C executable that makes use of preprocessor directives does not propage the arguments from --c-flag
during compilation of the executable.
The preprocessor works as expected for the library
target.
This behaviour is NOT present with Fortran preprocessor directives
Expected Behaviour
Propage preprocessor directives used to compile the library to the compilation of executables
Version of fpm
Platform and Architecture
Linux x64
Additional Information
MWE
fpm.toml*
name = "fpm-preproc-bug"
version = "0.1.0"
license = "license"
author = "gnikit"
maintainer = "giannis.nikiteas@gmail.com"
copyright = "Copyright 2022, gnikit"
[build]
auto-executables = true
auto-tests = true
auto-examples = true
[install]
library = false
[library]
include-dir = ["src"]
[[executable]]
name="mwe-c"
main="main.c"
[[executable]]
name="mwe-f90"
main="main.F90"
src/val.h
#ifndef _VAL_H_
#define _VAL_H_
#ifdef VAL
const int variable = 1;
#else
const int variable = 0;
#endif
#endif
src/valf.h
#ifdef VAL
integer, parameter :: variable = 1
#else
integer, parameter :: variable = 0
#endif
app/main.c
#include <stdio.h>
#include "val.h"
int main(){
printf("%d\n", variable);
}
app/main.F90
program main
#include "valf.h"
print*, variable
end program main
$ fpm run mwe-c --c-flag="-DVAL"
main.F90 done.
mwe-f90 done.
[100%] Project compiled successfully.
0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working