mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
* Header files that are used by a compilation must be declared
explicitly. If you forget a dependency, it's simply not visible to the compiler, and so the compilation fails. This is a big plus over conventional Make.
This commit is contained in:
parent
15646244ba
commit
08de98f8b6
7 changed files with 43 additions and 4 deletions
3
examples/default.nix
Normal file
3
examples/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[ (import ./trivial)
|
||||
(import ./simple-header)
|
||||
]
|
||||
11
examples/simple-header/default.nix
Normal file
11
examples/simple-header/default.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
let {
|
||||
|
||||
inherit (import ../../lib) compileC link;
|
||||
|
||||
hello = link {objects = compileC {
|
||||
main = ./hello.c;
|
||||
localIncludes = [ [./hello.h "hello.h"] ];
|
||||
};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
9
examples/simple-header/hello.c
Normal file
9
examples/simple-header/hello.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "hello.h"
|
||||
|
||||
int main(int argc, char * * argv)
|
||||
{
|
||||
printf("Hello " WHAT "\n");
|
||||
return 0;
|
||||
}
|
||||
1
examples/simple-header/hello.h
Normal file
1
examples/simple-header/hello.h
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define WHAT "World"
|
||||
|
|
@ -5,4 +5,4 @@ let {
|
|||
hello = link {objects = compileC {main = ./hello.c;};};
|
||||
|
||||
body = [hello];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue