Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

error: expected unqualified-id before '(' token #38

Open
lrusak opened this issue Nov 20, 2017 · 1 comment
Open

error: expected unqualified-id before '(' token #38

lrusak opened this issue Nov 20, 2017 · 1 comment

Comments

@lrusak
Copy link

lrusak commented Nov 20, 2017

Any idea what this is about?

/home/lukas/libreelec/build.LibreELEC-HiFive.riscv64-9.0-devel/riscv-fesvr-f683e01/fesvr/encoding.h:178:29: error: expected unqualified-id before '(' token
 #define write_csr(reg, val) ({ \
                             ^
/home/lukas/libreelec/build.LibreELEC-HiFive.riscv64-9.0-devel/riscv-fesvr-f683e01/fesvr/dtm.cc:393:17: note: in expansion of macro 'write_csr'
 uint64_t dtm_t::write_csr(unsigned which, uint64_t data)
                 ^~~~~~~~~

build log http://sprunge.us/LTBO

./build.LibreELEC-HiFive.riscv64-9.0-devel/toolchain/bin/riscv64-libreelec-linux-gnu-g++ --version
riscv64-libreelec-linux-gnu-g++-7.2.0 (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@Redleaf23477
Copy link

Redleaf23477 commented Mar 13, 2019

Hello,

write_csr is both used as macro (in encoding.h, line 198) and as function name (in dtm.cc, line 405), resulting in a compile error.

My solution (not a clever solution, though) is to comment the #include "encoding.h" and add #define CSR_DSCRATCH 0x7b2 in dtm.cc. Since CSR_DSCRATCH is a constant needed in dtm.cc defined in encoding.h but including encoding.h will cause naming conflict.

i.e. in dtm.cc
replace this

#include "dtm.h"
#include "debug_defines.h"
#include "encoding.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>

with this

#include "dtm.h"
#include "debug_defines.h"
// #include "encoding.h"
#define CSR_DSCRATCH 0x7b2
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <pthread.h>

Hope that there will be a bug fix soon!


Update 1: I put my compiling notes and a script to compile riscv-isa-sim in my repo. Hope it helps!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants