Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is a prototype and why do I want one?

prototype
0
Posted

What is a prototype and why do I want one?

0

Prototypes are function declarations, allowing a function in one C file to call another in a different C source file. For example, if you have the function void *get_free_frame(void) { … } add the prototype void *get_free_frame(void); to a header file which is #included by all C files which reference the function, even including the C file in which you define it. If you try to call this function without a proper prototype, you get the warning: warning: implicit declaration of function `get_free_frame’ and your programme may not work correctly. • How do I externalize data structures? First of all, it is generally better style to externalize functions using prototypes (see FAQ 15) than data structures. However, if you still want to, declare the external variable twice: once in a .h file with extern, and a second time in a .c file with no storage class. Do not declare the variable static. • How do I find out whether I am freeing enough memory? The easiest way is to count the calls to ma

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.