Function before and after main()

Did you start to execute functions before and after the main() function ?

you have two solutions to do that :

first solution is editing in the linker script

the second one is adding these prototypes in your source code

void start( void ) __attribute__ ((constructor)) ;

void end( void ) __attribute__ ((destructor));

and define you functions by adding any instructions you want to execute like that for example

void start()

{

   printf("Start\n");

}


void end()

{

   printf("end\n");

}

int main()

{

printf("Hello");

}

Finally when you compile this program you get excited

要查看或添加评论,请登录

Mohamed Salem的更多文章

  • Management of Bluetooth devices in Linux

    Management of Bluetooth devices in Linux

    Here I will talk about how to connect with a Bluetooth device in Linux using a command-line utility called…

  • Concurrent Queue

    Concurrent Queue

    Did you hear about the queue as a data structure ? ---- of course yes, But what is the concurrent queue, in nutshell…

    1 条评论
  • Priority Queue in C++

    Priority Queue in C++

    A priority queue in c++ is a type of container adapter, which processes only the highest priority element, i.e.

  • Bubble Sort in CPP

    Bubble Sort in CPP

    We will explain the simple sorting Algorithm which (Bubble Sort) Bubble Sort is a simple algorithm which is used to…

  • Global variables with the same name

    Global variables with the same name

    You know from the Build process that the compiler will export the global variables to the assembler and the assembler…

  • Command_line_arguments

    Command_line_arguments

    ???? ???? ?????? ???? ???????? ?? ?? command line arguments ???? ???? ???? ???????? ????? ????????? ???? ???? :O ????…

  • C_prototypes

    C_prototypes

    ??? ???? ?????? ????? ??????? ?? ????? ??? 1) int main(){} void main(){} ?????? ??????? ??? ??????? ????????? ??????…

  • Data Structures

    Data Structures

    https://drive.google.

  • Most Common Questions in Embedded C

    Most Common Questions in Embedded C

    https://drive.google.

社区洞察

其他会员也浏览了