- eliminate duplicate symbol names in modules

This commit is contained in:
Bryce Denney 2002-10-17 05:39:41 +00:00
parent 0710552145
commit d36c9f2643
3 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include <stdio.h>
#include "main.h"
#define _buildsym(sym) libmodule1_LTX_##sym
#include "modules.h"
void module_init ()
{

View File

@ -1,5 +1,7 @@
#include <stdio.h>
#include "main.h"
#define _buildsym(sym) libmodule2_LTX_##sym
#include "modules.h"
int n_operations = 0;

View File

@ -0,0 +1,17 @@
// This file is included by each module to rename all of its symbols, in order
// to avoid duplicate symbols in different modules. From the libtool docs:
// "Although some platforms support having the same symbols defined more than
// once it is generally not portable."
#define module_init _buildsym(module_init)
#define operate _buildsym(operate)
// Declare function prototypes in an extern "C" block so that C++ will not
// mangle their names (any more than we already have).
extern "C" {
void module_init();
int operate (int a, int b);
};
// Since the renaming and extern "C" stuff declaration is done in the
// header file, the actual code remains readable.