Help!! CC mangling works confusing!!
I have confusion about how CC mangling works for C code. Could you please give me a rule about when the mangling will be effect on the funcion?
In the following scenario, all three functions have been declared by extern "C" in queue.h, queue and queue2 have the same defination, but the queue2 has been declared again in queue.C.
Scenario:
bash-3.00$ more queue.h
extern "C" {
int *queue(char *q, void (*df)(void * object));
int *queue1(char *q, char *df);
int *queue2(char *q, void (*df)(void * object));
}
bash-3.00$ more queue.C
#include <stdio.h>
#include "queue.h"
int *queue(char *q, void (*df)(void * object))
{
printf("Test\n");
return 0;
}
int *queue1(char *q, char *df)
{
printf("Test1\n");
return 0;
}
extern "C" {
int *queue2(char *q, void (*df)(void * object))
{
printf("Test\n");
return 0;
}
}
queue.C
int *queue(queue_str *q, void (*df)(void * object))
{
print "Test\n";
}
On Solaris10 on x86, Sun Studio 11:
I compiled it by: C -w -c queue.C
Then
bash-3.00$ nm queue.o
queue.o:
[Index]ValueSizeType Bind Other ShndxName
[6]| 0|0|SECT |LOCL |0|6|
[2]| 0|0|SECT |LOCL |0|2|
[3]| 0|0|SECT |LOCL |0|3|
[4]| 0|0|SECT |LOCL |0|4|
[5]| 0|0|SECT |LOCL |0|5|
[7]| 0|54|FUNC |GLOB |0|2|__1cFqueue6FpcpFpv_v_pi_
[8]| 0|0|FUNC |GLOB |0|UNDEF |printf
[1]| 0|0|FILE |LOCL |0|ABS|queue.C
[9]|64|54|FUNC |GLOB |0|2|queue1
[10]|128|54|FUNC |GLOB |0|2|queue2
My question is why the function queue was mangled, but the queue1 and queue2 did not? I am appreciated for your response. Thanks!

