extern-c Questions

4

Solved

I see some code in C++ using extern "C" at the beginning of the file like this: #ifdef __cplusplus extern "C" {} #endif What does this mean? How does it work?
Aleshia asked 8/2, 2012 at 9:17

6

I know how to use extern "C" but what are the conditions when you have to use it? extern "C" tells the C++ compiler not to perform any name-mangling on the code within the braces. This allows y...
Encyst asked 3/11, 2011 at 14:1

6

Solved

I find such examples in Boost code. namespace boost { namespace { extern "C" void *thread_proxy(void *f) { .... } } // anonymous void thread::thread_start(...) { ... pthread_create(some...
Rochkind asked 7/4, 2010 at 16:31

7

Maybe I'm not understanding the differences between C and C++, but when and why do we need to use extern "C" { ? Apparently its a "linkage convention". I read about it briefly and noticed...
Exanthema asked 9/5, 2010 at 6:11

9

Solved

I'm taking a programming languages course and we're talking about the extern "C" declaration. How does this declaration work at a deeper level other than "it interfaces C and C++"? How does this ...
Spevek asked 8/3, 2010 at 17:49

2

Solved

Possible Duplicate: Why do we need extern “C”{ #include <foo.h> } in C++? I have often seen programs coded like: extern "C" bool doSomeWork() { // return true; } ...
Teal asked 18/8, 2009 at 6:30

3

Solved

I just got some C code that uses extern "C" to declare external functions like this: extern "C" void func(); Is this valid C? I'm getting an error at this line, but I'm not sure if it's because ...
Needs asked 4/4, 2009 at 20:12

10

Solved

Is there a side effect in doing this: C code: struct foo { int k; }; int ret_foo(const struct foo* f){ return f.k; } C++ code: class bar : public foo { int my_bar() { return ret_foo( ...
Rete asked 24/9, 2008 at 13:56

© 2022 - 2024 — McMap. All rights reserved.