blob: f7e0a5a900d3675613f0443fb0e9362ebb84f1ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//TEST(smoke):SIMPLE:
//TEST(smoke):SIMPLE: -file-system load-file
//TEST(smoke):SIMPLE: -file-system os
// Test support for `#pragma once`
// We will include two header files:
// one that uses `#pragma once`, and
// one that doesn't.
//
// The first file defines a function `foo()`,
// and the second defines a macro `BAR`
//
#include "pragma-once-a.h"
#include "pragma-once-b.h"
// We will include the files again, and
// before we do so we need to undefine
// the macro from the second file so
// that it doesn't get a redefinition diagnostic.
//
#undef BAR
//
// We don't do anything about the function
// in the first file, because we expect
// the `#pragma once` to cause it to be
// ignored on this second time.
//
#include "pragma-once-a.h"
#include "pragma-once-b.h"
// Make sure relative paths are handled
#include "./pragma-once-a.h"
#include "./pragma-once-a.h"
#include ".\pragma-once-a.h"
#include "./include\../pragma-once-a.h"
#include "../preprocessor/./pragma-once-a.h"
#include "include/pragma-once-c.h"
#include "./include\pragma-once-c.h"
#ifndef ONLY_DEFINED_ONCE_C
#undef BAR
#endif
// Now let's use both the function and the
// macro, to confirm that they are both
// defined as expected.
//
// Note: if we accidentally include file
// `a.h` more than once, we'd expect to
// get an error here, because the two
// function definitions conflict.
//
float test(float x)
{
return foo(x) + BAR(x);
}
|