Skip to content

Instantly share code, notes, and snippets.

@poyenc
Created August 29, 2012 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save poyenc/3516034 to your computer and use it in GitHub Desktop.
Save poyenc/3516034 to your computer and use it in GitHub Desktop.
ptt c_and_cpp (#1GFTfmiB)
#include "map.h"
int main() {
map_insert( "key", "value" );
return 0;
}
main.out: main.o map.o
g++ main.o map.o -o main.out
main.o: main.c
gcc -c main.c -o main.o
map.o: map.cpp
g++ -c map.cpp -o map.o
clean:
rm -f *.o *.out
#include "map.h"
#include <iostream>
#include <map>
using namespace std;
std::map<
std::string,
std::string
> internal_map;
extern "C" {
void map_insert( char const * key,
char const * value )
{
cout << "key: " << key << endl
<< "value: " << value << endl;
internal_map.insert( make_pair(key, value) );
}
}
#ifndef MAP_H
#define MAP_H
#ifdef __cplusplus
extern "C" {
#endif
void map_insert( char const * key,
char const * value );
#ifdef __cplusplus
}
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment