Skip to content

Commit 9805adc

Browse files
xusheng6claude
andcommitted
[emulator] Move intx include out of binaryninjaapi.h into emulator headers
binaryninjaapi.h does not provide the emulator API, so the wide-integer type it pulls in for the plugin does not belong there. Move the (windows.h min/max-guarded) intx include into a shared emulator_intx.h included by the emulator's own core and API roots instead. Addresses review feedback on PR #8314. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0d1183d commit 9805adc

4 files changed

Lines changed: 38 additions & 17 deletions

File tree

binaryninjaapi.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@
3131
#include "binaryninjacore.h"
3232
#include "exceptions.h"
3333

34-
// intx provides the wide-integer type used by the emulator plugin's API. If a
35-
// translation unit includes <windows.h> before this header (as several debugger
36-
// adapters do), its min/max macros would break intx's numeric_limits<>::min()/max()
37-
// member definitions. Neutralize those macros just for the intx include, then
38-
// restore them so any later code that relies on windows.h min/max is unaffected.
39-
#if defined(_WIN32)
40-
#pragma push_macro("min")
41-
#pragma push_macro("max")
42-
#undef min
43-
#undef max
44-
#endif
45-
#include "vendor/intx/intx.hpp"
46-
#if defined(_WIN32)
47-
#pragma pop_macro("min")
48-
#pragma pop_macro("max")
49-
#endif
50-
5134
#include "json/json.h"
5235
#include "rapidjsonwrapper.h"
5336
#include "vendor/nlohmann/json.hpp"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2020-2026 Vector 35 Inc.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
// intx provides the wide-integer type used throughout the emulator plugin's core and
20+
// API. It lives here (rather than in binaryninjaapi.h) so it is only pulled in by the
21+
// emulator's own headers. If a translation unit includes <windows.h> before this header
22+
// (as several debugger adapters do), its min/max macros would break intx's
23+
// numeric_limits<>::min()/max() member definitions. Neutralize those macros just for the
24+
// intx include, then restore them so any later code relying on windows.h min/max is
25+
// unaffected.
26+
#if defined(_WIN32)
27+
#pragma push_macro("min")
28+
#pragma push_macro("max")
29+
#undef min
30+
#undef max
31+
#endif
32+
#include "vendor/intx/intx.hpp"
33+
#if defined(_WIN32)
34+
#pragma pop_macro("min")
35+
#pragma pop_macro("max")
36+
#endif

plugins/emulator/api/emulatorapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
#pragma once
1818

1919
#include "binaryninjaapi.h"
20+
#include "emulator_intx.h"
2021
#include "ffi.h"
2122
#include <functional>
2223
#include <string>

plugins/emulator/core/ilemulator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include "binaryninjaapi.h"
4+
#include "../api/emulator_intx.h"
45
#include "ffi_global.h"
56
#include "refcountobject.h"
67
#include <atomic>

0 commit comments

Comments
 (0)