In C int foo()
and int foo(void)
are different functions. int foo()
accepts an arbitrary number of arguments, while int foo(void)
accepts 0 arguments. In C++ they mean the same thing. I suggest that you use void
consistently when you mean no arguments.
If you have a variable a
, extern int a;
is a way to tell the compiler that a
is a symbol that might be present in a different translation unit (C compiler speak for source file), don’t resolve it until link time. On the other hand, symbols which are function names are anyway resolved at link time. The meaning of a storage class specifier on a function (extern
, static
) only affects its visibility and extern
is the default, so extern
is actually unnecessary.
I suggest removing the extern
, it is extraneous and is usually omitted.
Related Posts:
- difference between
and - warning: initializer element is not computable at load time
- Why do I get “cast from pointer to integer of different size” error?
- Undefined reference to main – collect2: ld returned 1 exit status
- Where is the
header file on Linux? Why can’t I find ? - typedef fixed length array
- How to solve static declaration follows non-static declaration in GCC C code?
- Convert char to int in C and C++
- what is stack smashing (C)?
- warning: incompatible implicit declaration of built-in function ‘xyz’
- conflicting types error when compiling c program using gcc
- What is a file with extension .a?
- gcc/g++: “No such file or directory”
- How to initialize array to 0 in C?
- How to do scanf for single char in C
- Sign extend a nine-bit number in C
- Break statement not within loop or switch in C
- How to properly malloc for array of struct in C
- Cache Simulator in C
- make: Nothing to be done for `all’
- expected expression before ‘{‘ token
- Setting std=c99 flag in GCC
- C Vector/ArrayList/LinkedList
- Convert char array to a int number in C
- Bind failed: Address already in use
- What is the difference between %f and %lf in C?
- Debug vs Release in CMake
- What is stdin in C language?
- error: ‘for’ loop initial declarations are only allowed in C99 mode [duplicate]
- c – warning: implicit declaration of function ‘printf’
- Flushing buffers in C
- Compiling a .C file: Undefined symbols for architecture x86_64
- How to compile makefile using MinGW?
- Portable way to check if directory exists [Windows/Linux, C]
- How to use EOF to run through a text file in C?
- Incorrect checksum for freed object on malloc
- Removing trailing newline character from fgets() input
- How to copy a char array in C?
- Simple way to check if a string contains another string in C?
- What does “request for member ‘*******’ in something not a structure or union” mean?
- gcc: undefined reference to
- Segmentation fault (core dumped) due to fgets – I think
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- How to convert integer to char in C?
- What happens during a “relocation has invalid symbol index” error?
- Is there a good Valgrind substitute for Windows?
- Difference between “move” and “li” in MIPS assembly language
- Initializing array of structures
- Still Reachable Leak detected by Valgrind
- What is the difference between array and enum in C ?
- What is signed integer overflow?
- What does the term “empty loop” refer to exactly in C and C++?
- When to use const char * and when to use const char []
- What do numbers using 0x notation mean?
- What integer hash function are good that accepts an integer hash key?
- Can I create an Array of Char pointers in C?
- Proper way to empty a C-String
- Does stack grow upward or downward?
- malloc(): memory corruption
- X86 assembly – Handling the IDIV instruction
- error C2371: ‘functionname’ redefinition: different basic types
- Pause screen at program completion in C
- note: previous implicit declaration of ‘point_forward’ was here
- What exactly is meant by “de-referencing a NULL pointer”?
- Difference between fgets and fscanf?
- gcc -g :what will happen
- getc() vs fgetc() – What are the major differences?
- Can’t understand the working of getint() in C as per K&R
- Lua – Number to string behaviour
- Reading in double values with scanf in c
- Realloc Invalid Pointer in C
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- What tools are there for functional programming in C?
- “-bash: gcc: command not found” using cygwin when compiling c?
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- How to format strings using printf() to get equal length in the output
- What are the differences between if, else, and else if?
- Example of waitpid() in use?
- strtok segmentation fault
- Invalid write of size 1
- realloc(): invalid next size when reallocating to make space for strcat on char *
- C Error: declaration shadows a local variable — Won’t let me repeatedly replace the value of my float variable
- Can a function return two values?
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- MIPS to C Translation
- Pointer to 2D arrays in C
- How to know what the ‘errno’ means?
- Printf was not declared in this scope
- How to free memory from char array in C
- Can I get Unix’s pthread.h to compile in Windows?
- Initializing 2D char array in C
- GCC: Array type has incomplete element type
- Process exited with return value 3221225477
- gdb: No symbol “i” in current context
- %p Format specifier in c
- “Nothing to be done for makefile” message
- Convert Char to String in C
- What is the difference between signed and unsigned int