Skip to content

Commit

Permalink
Add missing includes. (#120)
Browse files Browse the repository at this point in the history
While there, allow "proxy_wasm_externs.h" externs to be exported
as either C (for Wasm) or C++ (for NullVM).

Signed-off-by: Piotr Sikora <[email protected]>
  • Loading branch information
PiotrSikora authored Jun 9, 2021
1 parent f094746 commit 9af5ac0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ cc_library(
"proxy_wasm_api.h",
"proxy_wasm_externs.h",
],
deps = [
":common_lib",
],
)

cc_library(
Expand Down
1 change: 1 addition & 0 deletions proxy_wasm_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// NOLINT(namespace-envoy)
#pragma once

#include <cstdint>
#include <string>

enum class WasmResult : uint32_t {
Expand Down
2 changes: 2 additions & 0 deletions proxy_wasm_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// NOLINT(namespace-envoy)
#pragma once

#include <cstdint>

enum class LogLevel : int32_t { trace, debug, info, warn, error, critical, Max = critical };
enum class FilterStatus : int32_t { Continue = 0, StopIteration = 1 };
enum class FilterHeadersStatus : int32_t {
Expand Down
3 changes: 3 additions & 0 deletions proxy_wasm_externs.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <stddef.h>
#include <stdint.h>

#include "proxy_wasm_common.h"
#include "proxy_wasm_enums.h"

//
// ABI
//
Expand Down

1 comment on commit 9af5ac0

@sitano
Copy link

@sitano sitano commented on 9af5ac0 Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch looks like a reasonable addition but it introduced a problem that is hard to fix now - as far as most headers here pollute the global/current namespace with the symbols adding cstdint to these 2 files pollutes the current namespace with namespace std {}. When these files (ie proxy_wasm_enums.h) are included in a non-global namespace (namespace A { #include "proxy_wasm_common.h" }) in descendant projects that do want to avoid polluting global namespace the current namespace appears to be polluted with a subset of std{} that duplicates definitions from ::std and prevents proper name resolution for missing symbols like std::string in the namespace, like in:

namespace A {

#include "proxy_wasm_common.h"

    std::string f() { return "oops, we have got a problem"; }
}

error: no type named 'string' in namespace 'A::std'; did you mean '::std::string'

Please sign in to comment.