I saw the use of #ifdef macros (such as the Eigen library) to control a specific platform, but I did not see anyone using the "built-in namespace" to control a specific platform code.
The github repo sheets provide specific code and usage examples.
https://github.com/dchichkov/curious-namespace-trick/wiki/Curious-Namespace-Trick
I am wondering if it is possible to use a viable technique or if there are any errors that I cannot see. The following is a snippet of code:
#include <stdio.h>
namespace project {
namespace arm {
inline void add_() {printf("arm add\n");}
}
inline void add_() {
printf("common add\n");
} inline namespace platform {inline void add() {add_();}}
inline void dot_() {
add();
} inline namespace platform {inline void dot() {dot_();}}
}
int main() {
project::dot();
return 1;
}
Exit:
$ g ++ func.cpp -Dplatform = common; ./ a.out general add
$ g ++ func.cpp -Dplatform = arm; ./ a.out arm add