Is this P/Invoke code standard?
If you don't call your function recursively from C, you don't need to have separate defition and declaration:

extern "C" __declspec(dllexport) int test(int val)
{
    return val * 2;
}


And if you have more than one function you want to export, you can use extern "C" as a block:

extern "C"
{
    __declspec(dllexport) int test(int val)
    {
        return val * 2;
    }

    // more functions here
}


As to what does it all mean:


extern "C" tells the compiler not to mangle the name of the function; this is normally necessary to support C++ function overloading
__declspec(dllexport) means that this function will be exported from the DLL, so that you can use it from outside this library