2
EXTERN(void) jpeg_fdct_8x4
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));

Here, I had four questions:

  1. What does the syntax Extern(Void) mean? That the return value is void? Is it a usual syntax?

  2. I see in a third-party code non-class member functions with the static keyword, inline keyword, no keyword and extern keyword. I understand that static keyword limits the scope of the function to the file. What happens if I use "no keyword"? Do I have to use extern in other file to use that function or I can call the function directly from another file after specifying the function declaration?

  3. Do I need extern in C++ only to call interface with C?

  4. What is the default scope of inline functions?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vkaul11
  • 4,098
  • 12
  • 47
  • 79

2 Answers2

2

EXTERN(n) is a preprocessor definition, to be found in jmorecfg.h:

  #define EXTERN(type)            extern type

So the above statement expands to

  extern void ...

For a writeup of extern in C code, check out this answer.

What happens if I use "no keyword"?

In this case the scope is not limited. Non static, global functions have their name visible to the linker across all compilation units, which means you get name clashes if different modules use the same function names.

3) Do I need extern in C++ only to call interface with C?

You presumably refer to extern "C" {} which instructs the compiler to use C calling convention. Yes, you need this to invoke external C functions from C++.

4) What is the default scope of inline functions?

The same scope as if they weren't declared inline.

Community
  • 1
  • 1
Alexander Gessler
  • 45,603
  • 7
  • 82
  • 122
  • Thanks "In this case the scope is not limited. Non static, global functions have their name visible to the linker across all compilation units, which means you get name clashes if different modules use the same function names." Can I just these functions directly in another file or I have to declare them before using them in the file? – vkaul11 Aug 27 '12 at 05:05
0

C++ is a case-sensitive language. The "extern" keyword is not the same as "EXTERN". It seems to be initializing a void function. You can use functions from other source files without using the extern keyword. e.g. When you are writing a project, the IDE will always start debugging and compiling with the main() function. You can declare and call functions in other files without using extern.