Re: Which spec has defined the calling sequence of static C functions (like the extern C functions' has been defined in the Sys V ABI specs)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/30/18 1:27 PM, Remus Clearwater wrote:
> Suddenly appear to me that it would be much tricky if some C library choose
> to export an extern C function pointer variable. I didn't notice such
> situation a moment ago.

That's easier to understand if you actually try an example.  Try this:

static int sum(int* a, int n) __attribute__((noinline));
static int sum(int* a, int n) {

  return *a + n;
}

int sum_n(int* a, int n) {
  return sum(a, n);
}

Compile it with

gcc -m32 -S -O3 z.c

Then add these lines to the file

typedef int sum_t(int *a, int n);

sum_t *sum_p(void) {
  return sum;
}

-- 
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux