This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Automatic accessor function inlining


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

file1.c:
static int _foobar;
int get_foobar () { return _foobar; }

file1.h:
int get_foobar ();

file2.c:
#include <stdio.h>
#include "file1.h"
int main (int argc, char **argv)
{
  int x = get_foobar ();
  printf ("x = %d\n", x);
  return 0;
}

Question: will gcc inline get_foobar()?
Consider this version instead:

file1.c:
int _foobar;

file1.h:
extern int _foobar;

file2.c:
#include <stdio.h>
#include "file1.h"
int main (int argc, char **argv)
{
  int x = _foobar;
  printf ("x = %d\n", x);
  return 0;
}

Will it be faster than the one with an accessor function?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJRQvKZAAoJEOs4Jb6SI2CwYwAH/2W9GWER/kysnzjltmg2GjKR
0QtZC3lycLLSt1o9YZavfpkgaq3RkpKxLX3hMfyQTFpRjWoLJIdbM8VGBTLTikmL
8A99TQ91Z9GaBckUFj8kK1h9v0OnqFlH1ZVJe7vkneoKwtlW9fjtPEKq3FqS/9WC
jMx2kZk5xi971txOjARVMw6v3dEI4cDJvdyqLicbccFWtq3PFf08GcTo1fzEd7Ge
ZuGasgb5CH4bYTVEdnyjZp1pMStRRuDY0PmQj7NLtXZcjU+XAR//0PufW4l3Cup4
I1vZ9RQeCIUILWj20XHbvVIsjAlrsDH3i63uTyFPzoVnTdHHLdiS+VF7+8+CFkM=
=+l0a
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]