Changeset 4640c75a8385ecb909a2b09d28eca23a6c4f6130

Show
Ignore:
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:
2 modified

Legend:

Unmodified
Added
Removed
  • c/benchmark/benchmark.h

    rad6683 r4640c7  
    99 
    1010#define BM_RUN_COUNT 6 
     11#ifdef __cplusplus 
     12#define BENCH(name) extern "C" void bm_##name(BenchMark *bm) 
     13#else 
    1114#define BENCH(name) void bm_##name(BenchMark *bm) 
     15#endif 
    1216 
    1317extern const char *WORD_LIST[]; 
  • c/benchmark/bm_hash.c

    rb36fbe r4640c7  
    44#endif 
    55#include <string.h> 
     6#ifdef __cplusplus 
     7extern "C" { 
     8#endif 
    69#include "hash.h" 
    710#include "benchmark.h" 
     11#ifdef __cplusplus 
     12} 
     13#endif 
    814 
    915#define N 20 
     
    1925        for (word = WORD_LIST; *word; word++) { 
    2026            h_set(h, *word, (void *)1); 
     27        } 
     28        for (word = WORD_LIST; *word; word++) { 
    2129            strcpy(buf, *word); 
    2230            res = (long)h_get(h, buf); 
     
    3139#include <ext/hash_map> 
    3240 
    33 using std::cout; 
    34 using std::endl; 
    3541using __gnu_cxx::hash_map; 
    3642 
     
    5157        long res; 
    5258        for (word = WORD_LIST; *word; word++) { 
    53             strcpy(buf, *word); 
    5459            dict[*word] = 1; 
     60        } 
     61        for (word = WORD_LIST; *word; word++) { 
     62            strcpy(buf, *word); 
    5563            res = dict[buf]; 
    5664        }