Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
86c8498c
Commit
86c8498c
authored
Aug 12, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transparently work around VOID and ERROR being #defined on Windows. Fixes #284.
parent
3aa2b2aa
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
52 additions
and
13 deletions
+52
-13
any.h
c++/src/capnp/any.h
+1
-0
c++.capnp.h
c++/src/capnp/c++.capnp.h
+1
-0
common.h
c++/src/capnp/common.h
+1
-0
json.capnp.h
c++/src/capnp/compat/json.capnp.h
+1
-0
capnpc-c++.c++
c++/src/capnp/compiler/capnpc-c++.c++
+2
-1
grammar.capnp.h
c++/src/capnp/compiler/grammar.capnp.h
+1
-0
lexer.capnp.h
c++/src/capnp/compiler/lexer.capnp.h
+1
-0
dynamic.h
c++/src/capnp/dynamic.h
+1
-0
layout.h
c++/src/capnp/layout.h
+1
-0
persistent.capnp.h
c++/src/capnp/persistent.capnp.h
+1
-0
rpc-twoparty.capnp.h
c++/src/capnp/rpc-twoparty.capnp.h
+1
-0
rpc.capnp.h
c++/src/capnp/rpc.capnp.h
+1
-0
schema.capnp.h
c++/src/capnp/schema.capnp.h
+1
-0
schema.h
c++/src/capnp/schema.h
+1
-0
gtest.h
c++/src/kj/compat/gtest.h
+1
-0
debug.h
c++/src/kj/debug.h
+1
-5
exception.h
c++/src/kj/exception.h
+1
-0
test.h
c++/src/kj/test.h
+1
-0
windows-sanity.h
c++/src/kj/windows-sanity.h
+33
-7
No files found.
c++/src/capnp/any.h
View file @
86c8498c
...
...
@@ -29,6 +29,7 @@
#include "pointer-helpers.h"
#include "orphan.h"
#include "list.h"
#include <kj/windows-sanity.h> // work-around macro conflict with `VOID`
namespace
capnp
{
...
...
c++/src/capnp/c++.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/common.h
View file @
86c8498c
...
...
@@ -32,6 +32,7 @@
#include <inttypes.h>
#include <kj/string.h>
#include <kj/memory.h>
#include <kj/windows-sanity.h> // work-around macro conflict with `VOID`
#if CAPNP_DEBUG_TYPES
#include <kj/units.h>
...
...
c++/src/capnp/compat/json.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if !CAPNP_LITE
#include <capnp/capability.h>
#endif // !CAPNP_LITE
...
...
c++/src/capnp/compiler/capnpc-c++.c++
View file @
86c8498c
...
...
@@ -2980,7 +2980,8 @@ private:
"
\n
"
"#pragma once
\n
"
"
\n
"
"#include <capnp/generated-header-support.h>
\n
"
,
"#include <capnp/generated-header-support.h>
\n
"
"#include <kj/windows-sanity.h>
\n
"
,
// work-around macro conflict with VOID
hasInterfaces
?
kj
::
strTree
(
"#if !CAPNP_LITE
\n
"
"#include <capnp/capability.h>
\n
"
...
...
c++/src/capnp/compiler/grammar.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/compiler/lexer.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/dynamic.h
View file @
86c8498c
...
...
@@ -41,6 +41,7 @@
#include "message.h"
#include "any.h"
#include "capability.h"
#include <kj/windows-sanity.h> // work-around macro conflict with `VOID`
namespace
capnp
{
...
...
c++/src/capnp/layout.h
View file @
86c8498c
...
...
@@ -37,6 +37,7 @@
#include "common.h"
#include "blob.h"
#include "endian.h"
#include <kj/windows-sanity.h> // work-around macro conflict with `VOID`
#if (defined(__mips__) || defined(__hppa__)) && !defined(CAPNP_CANONICALIZE_NAN)
#define CAPNP_CANONICALIZE_NAN 1
...
...
c++/src/capnp/persistent.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if !CAPNP_LITE
#include <capnp/capability.h>
#endif // !CAPNP_LITE
...
...
c++/src/capnp/rpc-twoparty.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/rpc.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/schema.capnp.h
View file @
86c8498c
...
...
@@ -4,6 +4,7 @@
#pragma once
#include <capnp/generated-header-support.h>
#include <kj/windows-sanity.h>
#if CAPNP_VERSION != 7000
#error "Version mismatch between generated code and library headers. You must use the same version of the Cap'n Proto compiler and library."
...
...
c++/src/capnp/schema.h
View file @
86c8498c
...
...
@@ -30,6 +30,7 @@
#endif
#include <capnp/schema.capnp.h>
#include <kj/windows-sanity.h> // work-around macro conflict with `VOID`
namespace
capnp
{
...
...
c++/src/kj/compat/gtest.h
View file @
86c8498c
...
...
@@ -30,6 +30,7 @@
// in the constructor, teardown in the destructor.
#include "../test.h"
#include <kj/windows-sanity.h> // work-around macro conflict with `ERROR`
namespace
kj
{
...
...
c++/src/kj/debug.h
View file @
86c8498c
...
...
@@ -112,11 +112,7 @@
#include "string.h"
#include "exception.h"
#ifdef ERROR
// This is problematic because windows.h #defines ERROR, which we use in an enum here.
#error "Make sure to to undefine ERROR (or just #include <kj/windows-sanity.h>) before this file"
#endif
#include "windows-sanity.h" // work-around macro conflict with `ERROR`
namespace
kj
{
...
...
c++/src/kj/exception.h
View file @
86c8498c
...
...
@@ -28,6 +28,7 @@
#include "memory.h"
#include "array.h"
#include "string.h"
#include "windows-sanity.h" // work-around macro conflict with `ERROR`
namespace
kj
{
...
...
c++/src/kj/test.h
View file @
86c8498c
...
...
@@ -28,6 +28,7 @@
#include "debug.h"
#include "vector.h"
#include "function.h"
#include "windows-sanity.h" // work-around macro conflict with `ERROR`
namespace
kj
{
...
...
c++/src/kj/windows-sanity.h
View file @
86c8498c
// Copyright (c) 2013-201
4
Sandstorm Development Group, Inc. and contributors
// Copyright (c) 2013-201
8
Sandstorm Development Group, Inc. and contributors
// Licensed under the MIT License:
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
...
...
@@ -19,20 +19,46 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// This file replaces poorly-named #defines from windows.h with properly-namespaced versions, so
// that they no longer conflict with similarly-named identifiers in other namespaces.
//
// This file must be #included some time after windows.h has been #included but before any attempt
// to use the names for other purposes. However, this can be difficult to determine in header
// files. Typically KJ / Cap'n Proto headers avoid including windows.h at all, but may use
// conflicting identifiers. In order to relieve application developers from the need to include
// windows-sanity.h themselves, we would like these headers to conditionally apply the fixes if
// and only if windows.h was already included. Therefore, this header checks if windows.h has been
// included and only applies fixups if this is the case. Furthermore, this header is designed such
// that it can be included multiple times, and the fixups will be applied the first time it is
// included *after* windows.h.
//
// Now, as long as any headers which need to use conflicting identifier names be sure to #include
// windows-sanity.h, we can be sure that no conflicts will occur regardless of in what order the
// application chooses to include these headers vs. windows.h.
#if !_WIN32
// Not on Windows. Tell the compiler never to try to include this again.
#pragma once
#if defined(__GNUC__) && !KJ_HEADER_WARNINGS
#pragma GCC system_header
#endif
#elif defined(_INC_WINDOWS)
#ifndef _INC_WINDOWS
#error "windows.h needs to be included before kj/windows-sanity.h (or perhaps you don't need either?)"
#endif
// We're on Windows and windows.h has been included. We need to fixup the namespace. We only need
// to do this once, but we can't do it until windows.h has been included. Since that has happened
// now, we use `#pragma once` to tell the compiler never to include this file again.
#pragma once
namespace
win32
{
const
auto
ERROR_
=
ERROR
;
#undef ERROR
const
auto
ERROR
=
ERROR_
;
typedef
VOID
VOID_
;
#undef VOID
typedef
VOID_
VOID
;
}
using
win32
::
ERROR
;
using
win32
::
VOID
;
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment