1a1a11a / libCacheSim

a high performance library for building cache simulators
GNU General Public License v3.0
159 stars 34 forks source link

Cannot compile test.c by the gcc command in README #2

Closed Yifei-Liu closed 3 years ago

Yifei-Liu commented 3 years ago

Got multiple errors and warnings while compiling test.c in the root directory of this repo by gcc $(pkg-config --cflags --libs libCacheSim glib-2.0) -lm -ldl test.c -o test. Here are the error messages:

gcc $(pkg-config --cflags --libs libCacheSim glib-2.0) -lm -ldl test.c -o test
test.c:6:20: error: initializer element is not constant
    6 | reader_t *reader = open_trace("data/trace.vscsi", VSCSI_TRACE, OBJ_ID_NUM, NULL);
      |                    ^~~~~~~~~~
test.c:9:18: error: initializer element is not constant
    9 | request_t *req = new_request();
      |                  ^~~~~~~~~~~
test.c:13:18: error: initializer element is not constant
   13 | cache_t *cache = create_cache("LRU", cc_params, NULL);
      |                  ^~~~~~~~~~~~
test.c:19:1: error: expected identifier or ‘(’ before ‘while’
   19 | while (read_one_req(reader, req) == 0) {
      | ^~~~~
test.c:27:1: warning: data definition has no type or storage class
   27 | close_trace(reader);
      | ^~~~~~~~~~~
test.c:27:1: warning: type defaults to ‘int’ in declaration of ‘close_trace’ [-Wimplicit-int]
test.c:27:1: warning: parameter names (without types) in function declaration
test.c:28:1: warning: data definition has no type or storage class
   28 | free_request(req);
      | ^~~~~~~~~~~~
test.c:28:1: warning: type defaults to ‘int’ in declaration of ‘free_request’ [-Wimplicit-int]
test.c:28:1: warning: parameter names (without types) in function declaration
test.c:28:1: error: conflicting types for ‘free_request’
In file included from /usr/local/include/libCacheSim/cacheObj.h:9,
                 from /usr/local/include/libCacheSim/cache.h:17,
                 from /usr/local/include/libCacheSim.h:13,
                 from test.c:3:
/usr/local/include/libCacheSim/request.h:71:20: note: previous definition of ‘free_request’ was here
   71 | static inline void free_request(request_t *req) {
      |                    ^~~~~~~~~~~~
test.c:29:6: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘->’ token
   29 | cache->cache_free(cache);
      |      ^~

This can be fixed by adding the main function in test.c. Also, I think it is a better practice to specify the build output (gcc -o option) as a different name instead of test, since a directory named as test already exists, which might occur cannot open output file test: Is a directory error.

1a1a11a commented 3 years ago

Great, thank you for the help! :) This project has stalled since my last update, I will merge your pull as soon as possible (need to finish the test suite).

1a1a11a commented 3 years ago

Also the example usages do not work because I had a large refactoring in the summer. If you would like to contribute some, it is also very appreciated. :)

Yifei-Liu commented 3 years ago

Thanks for the information, Jason. I am currently experimenting on this libCacheSim cache simulator, starting from running the examples in example/. I am very happy to make some contributions to let them workable if I am able to find some examples that do not work.

1a1a11a commented 3 years ago

Great! I am happy to help if you have any problem with the API or functions (the doc is not complete as well). Thank you!

On Nov 28, 2020, at 11:06 PM, Yifei Liu notifications@github.com wrote:

Thanks for the information, Jason. I am currently experimenting on this libCacheSim cache simulator, starting from running the examples in example/. I am very happy to make some contributions to let them workable if I am able to find some examples that do not work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/1a1a11a/libCacheSim/issues/2#issuecomment-735339959, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBP4T3TSGV67HEATSQQ42DSSHCDHANCNFSM4UGGY27Q.

1a1a11a commented 3 years ago

I will merge this for now, the test would need more work.

Yifei-Liu commented 3 years ago

Thanks, will deeply look into it. I will close this issue.