Skip to content

Instantly share code, notes, and snippets.

@vinzenz
Created August 26, 2009 20:47
Show Gist options
  • Save vinzenz/175827 to your computer and use it in GitHub Desktop.
Save vinzenz/175827 to your computer and use it in GitHub Desktop.
#!/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
#include <stdio.h>
#include "mod.h"
DEFINE_LOG_ID(TestApp);
int main()
{
printf("Hello World\n");
}
#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);
}
#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
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