In Objective-C, the __attribute__((constructor)) is used to specify a function that should be called automatically before main() function.

To delay the execution of a function by 1 second, you can use the dispatch_after function from the Grand Central Dispatch (GCD) framework. Here's an example:

#import <dispatch/dispatch.h>

static void myFunction(void) {
    // Code to be executed after 1 second
    NSLog(@"My function executed after 1 second");
}

static void __attribute__((constructor)) entry() {
    // Delay execution of myFunction by 1 second
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        myFunction();
    });
}

In the above code, the myFunction is defined as the function that will be executed after 1 second. The entry function is marked with the __attribute__((constructor)) attribute to ensure that it is called automatically before main().

Inside the entry function, the dispatch_after function is used to schedule the execution of myFunction after a delay of 1 second. The dispatch_time is used to calculate the time at which the block of code should be executed. The block is then dispatched to the main queue using dispatch_get_main_queue().

When the program runs, the myFunction will be executed after a delay of 1 second

Object-C 1秒后执行static void __attribute__constructor entry