Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22758

Picking up value of __attribute__ ((constructor)) function in main

$
0
0

I am trying to create a before-main evaluation like this:

int evaluate(int argc, char** argv) __attribute__ ((constructor));
int evaluate(int argc, char** argv)
{
    int result = atoi(argv[1]);
    if (result == 0)
        return 1;
    else
        return 0;
}

int main(?????)
{
    if (????? == 0)
        printf("Wrong number.");
    else
        printf("It is 1!");
}

Is there a way to do this? I am doing this purely to get myself more familiar with C, passing command line arguments and using pre-main functions.


Viewing all articles
Browse latest Browse all 22758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>