0

I know that extern C means the function should be compiled in C style however what does just extern function_datatype functionname mean?

extern void sharelog(const char *rem_host, const char *username,
         const char *, const char *,
         const char *, const char *);

What does extern without "C" mean?

Also, in almost every program's header files i see something along the lines of

void sharelog(const char *rem_host, const char *username,
         const char *, const char *,
         const char *, const char *);

Why declare the function again if it's been done in the .c/.cpp file? It's also sometimes declared without it's argument just

int Function;

Also, some functions can be written like this:

int CSomething::Somefunction() const

Why add const after the function?

I've also stumbled across functions which have these mysterious dots

void function(int prio, const char *fmt, ...)

There were a lot of other things i also wanted to ask, however it seems i already asked enough. I know some of you will probably say to go learn C/C++, however believe me, these stuff are not discussed for beginners.

sverre
  • 6,768
  • 2
  • 27
  • 35
dikidera
  • 2,004
  • 6
  • 29
  • 36

2 Answers2

1

The extern without "C" comes from pre-C++ times when you needed a way to tell the C compiler that a function is available "somewhere" and it should allow the linker to figure it out.

The declaration with extern allowed the compiler to add the function to the list of known names even if it couldn't resolve the address.

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820