I have a tool-chain in which header files are generated (by javac -h
, i.e. Java Native Interface), but the implementation of the functions is manually written. It would be really useful to get an error message when a supposed implementation function doesn’t actually implement a header-declared function (usually because the header function was updated).
I know how I would do that if the header functions were in a namespace:
#pragma once
namespace N
{
void f();
}
#include "header.hpp"
void N::f() { }
// good: compile error when you change the declaration in the header!
The function defined by N::f()
won’t compile without the declaration (in the header).
However, the generator doesn’t put stuff in namespaces (and I found no way to tell it to), so I tried the global namespace, but that is apparently not allowed:
#pragma once
void f();
#include "header.hpp"
void (::f)() { }
// error (on MSVC)
// warning "extra/explicit qualification on member 'f'" (on Clang/GCC)
I have to support MSVC, so suppressing the warning is not an option.
As a last resort, because all the functions are extern "C"
, I thought I could maybe wrap the #include "header.hpp"
in a namespace
, but that didn’t work either.
I’m out of ideas. Is this plain unsolvable?