Sponsored Content
Top Forums Programming Extern keyward on function in C Post 302971966 by Corona688 on Wednesday 27th of April 2016 03:06:01 PM
Old 04-27-2016
All functions are implicitly extern, yes, but there's sometimes more to be said.

Code:
// To use a C function from C++ you must warn the linker to expect 
// the symbol _functionname, not a C++ hashed overload like @kldsgjlakgjadls
extern "C" int functionname(int);

Also different linking specifications for different kinds of libraries, i.e. so's and dll's vs statically linked things. Sometimes the linker can handle that for you, but it's often more efficient, at least, to warn it in advance that it will be calling external library code.
 

10 More Discussions You Might Find Interesting

1. Programming

extern for functions

Hi, Please let me know if the extern keyword is necessary for using functions which is defined and declared in another file and and used in a different file where both these files are linked together. thanks (8 Replies)
Discussion started by: naan
8 Replies

2. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

3. Programming

Extern variable.

file1.c int a1; int main() { a1 = 2; printf("\na1 = %d\n", a1); next(); printf("\na1 = %d\n", a1); next1(); printf("\na1 = %d\n", a1); } file2.c #include <stdio.h> int b1 = 0; void next(void) (1 Reply)
Discussion started by: Tanvirk
1 Replies

4. Linux

Problem mounting extern hd (fedora 9)

Hi there, I'm having a bit of a strange problem which I would appreciate some help with. The Problem: I have two external hard drives, but I'm borrowing one off my parents to copy data too (one of mine, which is identical to theirs - WD MyBook 300g - is on its way out). Fedora 9 recognizes... (3 Replies)
Discussion started by: lasthidingplace
3 Replies

5. UNIX for Dummies Questions & Answers

fetchmail and forward to an extern address

Hi, I'm searching for an solution for the following problem. I want fetch some mails via pop3 from a@a.com with fetchmail. That works perfectly. Now any incoming mail should forwarded to b@b.com via smtp obv. But I don't know how to configure that. All online tutorials describe forwarding to... (0 Replies)
Discussion started by: mcW
0 Replies

6. Shell Programming and Scripting

Return a value from called function to the calling function

I have two scripts. script1.sh looks -------------------------------- #!/bin/bash display() { echo "Welcome to Unix" } display ----------------------------- Script2.sh #!/bin/bash sh script1.sh //simply calling script1.sh ------------------------------ (1 Reply)
Discussion started by: mvictorvijayan
1 Replies

7. Programming

segmentation fault for extern

Why this is happening when both of them compiled together and run? I am getting segmentation fault SIGSEGV. File1.c: int arr; File2.c: extern int *arr; int main() { arr = 100; } (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. Programming

C header file and extern

In the header file data.h i got: const char ack_msg = "ack: received your msg\n"; In the code file server.c i got: extern const char ack_msg; And else it is only used in a function call: user$ grep ack_msg *c *h server.c:extern const char ack_msg; server.c: n = write(clientsfd,... (5 Replies)
Discussion started by: tornow
5 Replies

9. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

10. Shell Programming and Scripting

Function - Make your function return an exit status

Hi All, Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition. #Body function1() { if then echo "exist" else echo "not exist" } #if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
end(3)							     Library Functions Manual							    end(3)

NAME
end, _end, _ebss, etext, _etext, edata, _edata, eprol, _ftext, _fdata, _fbss, _procedure_table, _procedure_table_size, _proce- dure_string_table, __istart, __fstart, _DYNAMIC, _DYNAMIC_LINK, _BASE_ADDRESS, _GOT_OFFSET, _cobol_main - locations in program and defini- tions in runtime procedure table SYNOPSIS
extern unsigned long end; extern unsigned long _end; extern unsigned long _ebss; /* First address above a program's */ /* uninitialized data region */ extern unsigned long etext; extern unsigned long _etext; /* First address above the text region */ extern unsigned long edata; extern unsigned long _edata; /* First address above the initialized */ /*data region */ extern unsigned long eprol; /* First instruction of the user's program */ /* that follows the runtime startup routine */ extern unsigned long _ftext; /* Start address of the text region */ extern unsigned long _fdata; /* First address of the initialized data */ /* region */ extern unsigned long _fbss; /* Start address of the uninitialized data */ /* region */ extern unsigned long _procedure_table; extern unsigned long _procedure_table_size; extern unsigned long _procedure_string_table; /* See under DESCRIPTION */ extern unsigned long __istart; /* Start address of the program's */ /* initialization function driver routine */ extern unsigned long __fstart; /* Start address of the program's */ /* termination function driver routine */ extern unsigned long _DYNAMIC; /* Address of a shared object's dynamic */ /* header table */ extern unsigned long _DYNAMIC_LINK; /* Identifies the link type of a program */ /* or shared library. 0 for non_shared, */ /* 1 for call_shared and 2 for shared */ extern unsigned long _BASE_ADDRESS; /* First mapped address of a program or */ /* shared library */ extern unsigned long _GOT_OFFSET; /* Address of the global offset table in */ /* a shared program or shared library */ extern unsigned long _cobol_main /* Address of the main routine in a cobol */ /* program */ DESCRIPTION
These names refer neither to routines nor to locations with interesting contents except for _procedure_table, _procedure_string_table, and, for Tru64 UNIX, __istart and __fstart. Except for eprol, these are all names of linker-defined symbols. Note that the end, etext, and edata symbols are not defined when you compile in ANSI mode. When execution begins, the program break coincides with _end, but it is reset by the routines brk(2), malloc(3), standard input/output, the profile (-p) option of cc(1), etc. The current value of the program break is reliably returned by "sbrk(0)"; (see brk(2)). The linker-defined symbols _procedure_table, _procedure_table_size, and _procedure_string_table refer to the data structures of the runtime procedure table. Because these are linker-defined symbols, the data structures are built by ld(1) only if they are referenced. See the include file sym.h for the definition of the runtime procedure table, and see the include file exception.h for its uses. These symbols are all absolute symbols; the value of each symbol is its address (for example, "&_procedure_table_size"). Any reference to the symbol itself will attempt to access the symbol's value as if it were a valid address and will most likely result in an access viola- tion. All of these symbols except for end, _end, eprol, __istart, and _cobol_main are defined as local symbols in an executable or shared library's dynamic symbol table. Consequently, an executable or shared library can only reference its own definitions of these local sym- bols. RELATED INFORMATION
brk(2), malloc(3). delim off end(3)
All times are GMT -4. The time now is 05:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy