answersLogoWhite

0


Best Answer

For gcc there's a non-standard solution. Declare the function with __attribute__((constructor)) (note the double parentheses).

Like this:

void init(void) __attribute__ ((constructor));

void init(void) {

// your code goes here

}

Starting with gcc 4.3 there's even a possibility to assign a priority to the "constructor". See http://gcc.gnu.org/onlinedocs/gcc-4.3.0/gcc/Function-Attributes.html for details.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

main()

Technically, the first function executed is the library entry point, but that does not count from a programmer's perspective.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the first function executed in a C plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a main function in c plus plus?

It is the first function that gets called when the program is executed.


What is the only function all C plus plus programs must contain?

Every C plus plus program that is a main program must have the function 'main'.


Is C plus plus interpreted as the program is executed?

No. Neither C nor C++ are interpreted. Both need to be compiled and linked to produce highly-optimised machine code, which is then executed.


What is a primary function in C plus plus?

There is no such thing. You probably meant the main function. The main function is the only function that is required as it serves as the entry point of the program.


Where is the global declaration section of a c plus plus program?

Anything declared outside of a function is global.


What is the importance of functions in a c plus plus program?

Functions are very important in C++, as you can't write the simplest program to print hello without using a function. Overall you can say that function are building blocks of a C++ program. Functions can also be defined by the programmer to reduce program size.


How do you write a programm in c plus plus without using function main?

I don't think its possible. Every C++ program must at least have the main function.


What is meant by abstraction in c plus plus?

Abstraction is a process by which higher concepts are derived from the usage and classification of literal ("real" or "concrete") concepts, first principles and/or other abstractions.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


Can a function be called from more than one place in a program in c plus plus?

In C and C++, as well as in many (all?) languages, a function can be called from more than one place in a program. That's the purpose of functions - to encapsulate pieces of code that are needed in more than one place in the program.


Why wont your c plus plus program stay open?

If you are talking about the program executing, but the output screen being displayed for a flash and then disappearing, I suggest adding getch() or getchar() function at the end of your main function. This will make sure that the output screen waits for you to press a character before the program terminates.


Define multi function in c plus plus?

Multi-function simply means more than one function. Every program must have at least one function, the main function (the entry point of the application), and although you can write an entire program using just this one function, breaking the program down into several smaller functions makes the code easier to read and maintain. A major advantage of multi-function programming is that functions can be called as often as required -- there is no need to write the same piece of code over and over again.