Created
August 29, 2012 17:39
-
-
Save poyenc/3516034 to your computer and use it in GitHub Desktop.
ptt c_and_cpp (#1GFTfmiB)
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 "map.h" | |
int main() { | |
map_insert( "key", "value" ); | |
return 0; | |
} |
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
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 |
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 "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) ); | |
} | |
} |
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 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