6

I am trying to compile some code from Github on my, (up to date), Centos 6.5 using GCC++.
But I get the error message below when I try to compile the code.

The line below is the one failing:

...
#define __STDC_FORMAT_MACROS 1

...
#include <inttypes.h>

...
inline std::string i64tostr(int64_t n)
{
  return strprintf("%"PRId64, n);   // <-- errors here.
}

...

And the error is:

error: expected ')' before 'PRId64

What could be the issue and how do I resolve it?

Edit 1: This is the line of code failing.
https://github.com/rat4/blackcoin/blob/master/src/util.h#L226

Edit 2: replacing the code with printf("%" PRId64, n); (note the extra space), as suggested in the proposed answer does not work, (the same error message is given).

FFMG
  • 1,208
  • 1
  • 10
  • 24
  • It works OK for me: http://coliru.stacked-crooked.com/a/f3aff44dd52c22be - are you sure you have all the relevant #includes ? Any warnings or other issues in the preceding lines ? – Paul R Sep 23 '14 at 08:46
  • 1
    This - http://stackoverflow.com/questions/11869593/c99-printf-formatters-vs-c11-user-defined-literals - is an answer – borisbn Sep 23 '14 at 08:46
  • 1
    BTW, it would be better (for future) to include the compiler version and compile parameters in a question – borisbn Sep 23 '14 at 08:49
  • I added the link to the github code. As I said, I have Centos 6.5 all up to date including GCC – FFMG Sep 23 '14 at 08:51
  • What is `strprintf` ? Can you post a MCVE? – M.M Sep 23 '14 at 09:53
  • 1
    Looking further up in the source file, there is suggestion that perhaps your compiler doesn't support inttypes.h properly, add in `#ifndef PRId64` `#error Lame compiler detected` `#endif` – M.M Sep 23 '14 at 10:03
  • @MattMcNabb, the error does trigger, so that implies that something might have gone wrong somewhere in my install of gcc (?). I have version 4.7.2, is there somewhere I could re-install inttypes.h? – FFMG Sep 23 '14 at 10:17
  • @FFMG are you using -std=c++11 flag in compiling? It's help to change your code to a MCVE, and also post your commandline for compiling it – M.M Sep 23 '14 at 20:37

1 Answers1

0

It seems, that the error is somewhere outer. Look - http://ideone.com/dqeMTY - I copied your code, but I mistaked and missed # sign before define __STDC_FORMAT_MACROS 1, and ... I've got the same error near PRId64. Try to comment a half of code before suspicious line, then another half and so on.

borisbn
  • 4,988
  • 25
  • 42