Changeset 4640c75a8385ecb909a2b09d28eca23a6c4f6130
- Timestamp:
- 04/21/08 09:19:13 (9 months ago)
- Author:
- krayouva <krayouva@…>
- Parents:
- 3e94658359c07330b5ea11ae8520fd41e676bba5
- Children:
- 63d246bfa1ad0af79d78e35671481fbfa7ad3129
- git-committer:
- krayouva <krayouva@gmail.com> / 2008-04-20T19:19:13Z-0400
- Message:
-
* C++ code wasn't compiling for me because of C linkage
- We'll need to add the extern "C" linkage to our headers at some point so
that they compile under g++
- Location:
- c/benchmark
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rad6683
|
r4640c7
|
|
| 9 | 9 | |
| 10 | 10 | #define BM_RUN_COUNT 6 |
| | 11 | #ifdef __cplusplus |
| | 12 | #define BENCH(name) extern "C" void bm_##name(BenchMark *bm) |
| | 13 | #else |
| 11 | 14 | #define BENCH(name) void bm_##name(BenchMark *bm) |
| | 15 | #endif |
| 12 | 16 | |
| 13 | 17 | extern const char *WORD_LIST[]; |
-
|
rb36fbe
|
r4640c7
|
|
| 4 | 4 | #endif |
| 5 | 5 | #include <string.h> |
| | 6 | #ifdef __cplusplus |
| | 7 | extern "C" { |
| | 8 | #endif |
| 6 | 9 | #include "hash.h" |
| 7 | 10 | #include "benchmark.h" |
| | 11 | #ifdef __cplusplus |
| | 12 | } |
| | 13 | #endif |
| 8 | 14 | |
| 9 | 15 | #define N 20 |
| … |
… |
|
| 19 | 25 | for (word = WORD_LIST; *word; word++) { |
| 20 | 26 | h_set(h, *word, (void *)1); |
| | 27 | } |
| | 28 | for (word = WORD_LIST; *word; word++) { |
| 21 | 29 | strcpy(buf, *word); |
| 22 | 30 | res = (long)h_get(h, buf); |
| … |
… |
|
| 31 | 39 | #include <ext/hash_map> |
| 32 | 40 | |
| 33 | | using std::cout; |
| 34 | | using std::endl; |
| 35 | 41 | using __gnu_cxx::hash_map; |
| 36 | 42 | |
| … |
… |
|
| 51 | 57 | long res; |
| 52 | 58 | for (word = WORD_LIST; *word; word++) { |
| 53 | | strcpy(buf, *word); |
| 54 | 59 | dict[*word] = 1; |
| | 60 | } |
| | 61 | for (word = WORD_LIST; *word; word++) { |
| | 62 | strcpy(buf, *word); |
| 55 | 63 | res = dict[buf]; |
| 56 | 64 | } |