Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Noel_B_
Beginner
137 Views

extern "C" not working with Linux icpc but works find with Mac

Jump to solution

Attached is simple reproducer that works on Mac with:

 

s1038899:~ kbelco$ icpc --version

icpc (ICC) 19.1.3 20200925

Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

 

but fails on Linux with Intel 19.1.4

 

The name mangling is different, you get the leading underscore on the Mac which is correct but on Linux you don't get the leading underscore.

 

I have to inline the source code since the attachment is rejected.

 

#include "junk.hpp"

 

int foo(char*) {

  return 0;

}

void foo2(char*) {

}

int main(int, char**) {

  return 0;

}

 

Here's the Mac output:

s1038899:~ kbelco$ nm a.out | grep -i foo

0000000100000c10 T _foo

0000000100000c20 T _foo2

 

Here's the Linux output:

 

-bash-4.2$ nm a.out | grep -i foo

0000000000400c40 T foo

0000000000400c50 T foo2

0 Kudos

Accepted Solutions
Gopika_Intel
Moderator
73 Views

Hi,

 

Thank you for reaching out. We’ll check it and get back to you.

 

Regards

Gopika Ajit


View solution in original post

2 Replies
Gopika_Intel
Moderator
74 Views

Hi,

 

Thank you for reaching out. We’ll check it and get back to you.

 

Regards

Gopika Ajit


View solution in original post

Viet_H_Intel
Moderator
66 Views

On Linux, it needs to be compatible with Gnu. If icpc generated _foo symbol, then there would be an "undefined reference to foo" when you try to link mix objects (compile with icpc/g++).


Thanks,