Hi, here is a re-worked version of the patch. Compilers: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86 (from the free Studio Express 2010 package) gcc and g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 Problem:
Having an extern "C" variable/function in the namespace scope is allowed by the standard. However, there are some limitations which effectively deny the purpose of namespaces. That is, according to [dcl.link]
"At most one function with a particular name can have C language linkage. Two declarations for a function with C language linkage with the same function name (ignoring the namespace names that qualify it) that appear in different namespace scopes refer to the same function. Two declarations for an object with C language linkage with the same name (ignoring the namespace names that qualify it) that appear in different namespace scopes refer to the same object."
For instance, in the code below
namespace A { extern "C" int f(); }
namespace B { extern "C" void f(); }
A::f() and B::f() actually refer to the same function! In my opinion it's very confusing, and we'd better avoid using extern "C" functions (and variables) in the namespace scope.
Second problem: MSVC has a bug where extern "C" declarations inside a namespace do not produce the same linker symbol as when they are used outside a namespace. The linker then produces "unresolved externals" error messages. Solution: Moved the following extern "C" declarations out of the cln namespace and prefixed them with cln_ : mulu32_high mulu64_high divu_16_rest divu_32_rest divu_64_rest N.B. There are more linker errors with MSVC, but I will address these in a separate patch. Best regards, Jan