Trying To Learn 'extern'

closed account (zb0S216C)
I'm trying to learn how to use the extern keyword. I'm not understanding it very good if I'm honest. So far, this is what I've got:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
extern "C"
{
    struct Struct
    {
        int Value;
    };

    int Struct_Init( struct Struct *This_object, int Init_value );
}

int main( )
{
    //...
}


How would I call Struct_Init( ) as if it were a C++ method? Any resources or an example will be appreciated.
Last edited on
All extern "C" says in this case is that the compiler should not mangle the names inside the extern C block. This means that if you had a pure C file which you compiled with the C compiler, you would be able to call the function.

From a programming standpoint, you use them the same way either way.
closed account (zb0S216C)
That makes sense. Thanks jsmith.
Topic archived. No new replies allowed.