Created
August 26, 2009 20:47
-
-
Save vinzenz/175827 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
gcc -c mod.c -o mod.o | |
gcc -c main.c -o main.o | |
g++ -c mod_loader.cc -o mod_loader.o | |
g++ mod.o main.o mod_loader.o -o test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mod.h" | |
DEFINE_LOG_ID(TestApp); | |
int main() | |
{ | |
printf("Hello World\n"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "mod.h" | |
extern char const * logging_init_data[]; | |
void init_logger() | |
{ | |
logging_create_module_info(logging_init_data[0], logging_init_data[1], logging_init_data[2] ); | |
} | |
void* | |
logging_create_module_info (const char* header_location, | |
const char* stream_location, | |
const char* id) | |
{ | |
printf( "C init func called\n" | |
"header_location: %s\n" | |
"stream_location: %s\n" | |
"id: %s\n", header_location, stream_location, id); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef LIBLOG_LOG_H_INCLUDED | |
#define LIBLOG_LOG_H_INCLUDED | |
void* | |
logging_create_module_info (const char* header_location, | |
const char* stream_location, | |
const char* id); | |
#define DEFINE_LOG_ID_IMPL(HEADER_LOCATION, ID) \ | |
char const * logging_init_data[] = { HEADER_LOCATION, __BASE_FILE__, # ID } | |
#define DEFINE_LOG_ID(ID) \ | |
DEFINE_LOG_ID_IMPL (__FILE__, ID) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" void init_logger(); | |
namespace { | |
struct init_it{ init_it(){ init_logger(); } }; | |
static init_it do_init; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment