[cfe-dev] Why this extern "C" fails ?

Arji Cot arjicot at gmail.com
Mon Jul 29 22:45:29 PDT 2013


Yes it works, but it's not reflecting my case.

2013/7/29 Ólafur Waage <olafurw at gmail.com>

> This works fine, IIRC the extern must be in global scope.
>
> #include <iostream>
>
>
> extern "C" {
>     int a = 42;
> }
>
> int main() {
>   {
>
>     { std::cout << a << "\n"; }
>   }
>   return (0);
> }
>
>
>
>
> On Mon, Jul 29, 2013 at 2:06 PM, Ólafur Waage <olafurw at gmail.com> wrote:
>
>> What is your compile line?
>>
>>
>> On Mon, Jul 29, 2013 at 1:56 PM, Arji Cot <arjicot at gmail.com> wrote:
>>
>>> --------------
>>>
>>> #include <iostream>
>>>
>>> int main() {
>>>   {
>>>     extern "C" { int a = 42; }
>>>     { std::cout << a << "\n"; }
>>>   }
>>>   return (0);
>>> }
>>>
>>> --------------
>>>
>>> this code fails to compile and the compiler message alone
>>>
>>> main.cpp:5:12: error: expected unqualified-id
>>>     extern "C" { int a = 42; }
>>>            ^
>>> 1 error generated.
>>>
>>> It's not enough to me to explain why this is not working.
>>>
>>> There is something that I'm missing ?
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130730/7fea46c6/attachment.html>


More information about the cfe-dev mailing list