1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// weak2.c
#include "test.h"
typedef void (*vlc_plugin_cb)(void);
// Simulate VLC_WEAK macro
#define VLC_WEAK __attribute__((weak))
// Weak symbol declaration
VLC_WEAK
extern const vlc_plugin_cb vlc_static_modules[];
// Function using the weak symbol
void init_plugins(void) {
if (!vlc_static_modules) {
printf("vlc_static_modules not defined\n");
return;
}
for (unsigned i = 0; vlc_static_modules[i]; i++) {
printf("Plugin %u initialized\n", i);
vlc_static_modules[i]();
}
}
// Dummy plugin
void plugin1(void) {
printf("Plugin1 executed\n");
}
// Uncomment to define the weak array for testing
const vlc_plugin_cb vlc_static_modules[] = { plugin1, NULL };
int main() {
init_plugins();
printf("Test completed\n");
return 0;
}
|