logo
down
shadow

Use function pointer initialized in other source file


Use function pointer initialized in other source file

By : Mradul06
Date : November 22 2020, 10:56 AM
it should still fix some issue I have function pointer, that is declared as follows in file 1.h , Check the below changes
code :
// file : 1.h
typedef void (*my_func_ptr_T)(int , int);
extern my_func_ptr_T func;

//file 1.c
#include "1.h"

//func is visible


// file 2.c
#include "1.h"

//func is visible


Share : facebook icon twitter icon
Use an un-initialized pointer as a function parameter

Use an un-initialized pointer as a function parameter


By : user3036271
Date : March 29 2020, 07:55 AM
I hope this helps . In Body * &b b is an alias of/reference to the b in main - so when you assign to it you modify the b in main. In Body* b b is a local copy of the b in main, you're modifying this local copy and not the b in main.
Your runtime error is likely due to using the uninitialized b in main.
Assigning a void pointer from function works in one source file, but not in two

Assigning a void pointer from function works in one source file, but not in two


By : mounika mouni
Date : March 29 2020, 07:55 AM
this one helps. In your file1.c, it seems the declaration of void *foo() is missing. You can either include the header file containing this declaration or add line void *foo() on top of file1.c.
When compiler finds symbol foo followed by ( in main file, and there was no declaration, it assumes foo accepts any number of arguments and returns an int. So you see the warning that int is being converted to a pointer.
Returning pointer from function after being initialized to non-local pointer

Returning pointer from function after being initialized to non-local pointer


By : Perl Programmer
Date : March 29 2020, 07:55 AM
this one helps. There is nothing wrong with local pointers; the problem is with returning a pointer to a local thing. Recall why this is bad: when the function returns, the memory used by that thing can be re-used for other things.
modify_p_x is given a pointer to x (allocated in main), uses it to change x, and returns that pointer, which main then re-assigns to p_x. Except for how it is used, this is no different than if you were using ints instead of pointers, and I don't think you ever worried about returning an int variable.
Exposing static pointer in some source file to main.c via function

Exposing static pointer in some source file to main.c via function


By : user3721999
Date : March 29 2020, 07:55 AM
Does that help You're overwriting the local copy of the variable. Instead, pass a pointer to a pointer:
code :
    exposeStatic(&s);
void exposeStatic(struct node **v)
{
    *v = myStatic;
}
in C++, why my pointer to a function cannot be initialized?

in C++, why my pointer to a function cannot be initialized?


By : David
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Code can not be run outside a function.
This is trying to run code:
Related Posts Related Posts :
  • Program works but outputs trailing garbage values
  • Letting 2 pointer pointing to same address
  • Different ways to print the two-dimensional array's contents
  • C Programming : Confusion between operator precedence
  • C code inside a loop not being executed
  • C - Weird symbols
  • C - Get pointer adress to string
  • how to start a function using a Struct?
  • Trying to tweak sscanf() to ignore \n and \t
  • How to find the inverse of a Rectangular Matrix in C using GSL
  • sizeof() showing different output
  • How to select/read/copy values after specific character in a string
  • Jump from bootloader generates exception
  • Array dropping values, picks up garbage
  • Swig: Syntax error in input(3)
  • multiple definition and making sure function is correctly written
  • MD4 openssl core dumped
  • Undefined-Behavior at its best, is it -boundary break? -bad pointer arithmetic? Or just -ignore of aliasing?
  • Why am i getting problem3.c:20:23: error: expected expression before ‘int’?
  • Right Justified Zero filled String in C
  • C Function with parameter without type indicator still works?
  • How to transmit data from an interrupt handler to an user application?
  • Why do I get the error "bash: ./a.out: Permission denied" when I execute a C program in Linux mint 15
  • syntax of sigchld and its declaration
  • error using g_idle_add() in C++, same thing works in C
  • why if else or nested if else are called single statement in C
  • How do I interpret this printf in C
  • load the functions of a shell script without executing it
  • Is FilterSendNetBufferLists handler a must for an NDIS filter to use NdisFSendNetBufferLists?
  • How to write to flash memory using inline assembly?
  • More Return Statements vs. More Indentation
  • How to show an image on a PictureBox from resource?
  • Having malloced some memory,I could't calculator the proper size of the memories I malloced.I don't know why
  • What is the main difference between integer pointer and character pointer?
  • Why are some functions declared extern and header file not included in source in Git source code?
  • what is the use of fflush(stdin) in c programming
  • Is it safe to return file File descriptor locally allocated from another function In C
  • Changing undefined values of an array
  • What does an empty parameter list mean?
  • using strtol on a string literal causing segmentation fault
  • Same structure objects memory overlap?
  • C-Linux-Any way to pass command "history" to Linux shell?
  • Using #define in defining string size C
  • How to use thread pool and message queues in Multithreaded Matrix Multiplication?
  • Can't find how to select path to run a C program
  • Automatic variable in C not initialized but given fixed value within loop
  • main() function defined without return type gives warning
  • Output of following code with integer, float, char variable
  • why buffer memory allocation error in opencl
  • Why am I getting this error during run-time?
  • Strange behaviour of the pow function
  • task in increment , decrement , printf() , why these are evaluated in this manner in C
  • 28 extra bytes in bss
  • Waiting for multiple events without polling
  • Why are my variables reporting as "undeclared identifier" when compiling?
  • Correct AddNode function but somehing happens when I printf
  • When I traverse in the splay tree, then now which one is root?
  • Data type conversion in Postfix evaluation
  • No output in terminal (Head First C)
  • Data writes over after realloc
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org