osandov / blktests

Linux kernel block layer testing framework
118 stars 75 forks source link

compiling error with make command #31

Closed yizhanglinux closed 6 years ago

yizhanglinux commented 6 years ago

Hello I met bellow error when do make command, did I missed something? [root@storageqe-62 blktests]# make make -C src all make[1]: Entering directory /mnt/tests/kernel/storage/SSD/nvme_blktest/blktests/src' g++ -O2 -Wall -Wextra -Wno-sign-compare -o discontiguous-io discontiguous-io.cpp discontiguous-io.cpp: In member function ‘void iovec_t::append(void*, size_t)’: discontiguous-io.cpp:60:3: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat] auto p = m_v.end() - 1; ^ discontiguous-io.cpp:60:8: error: ‘p’ does not name a type auto p = m_v.end() - 1; ^ discontiguous-io.cpp:61:3: error: ‘p’ was not declared in this scope p->iov_base = addr; ^ discontiguous-io.cpp: In member function ‘size_t iovec_t::data_len() const’: discontiguous-io.cpp:69:8: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat] for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:69:13: error: ‘p’ does not name a type for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:69:30: error: expected ‘;’ before ‘p’ for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:69:30: error: ‘p’ was not declared in this scope discontiguous-io.cpp: In member function ‘void iovec_t::trunc(size_t)’: discontiguous-io.cpp:75:8: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat] for (auto p = m_v.begin(); p != m_v.end(); ++p) { ^ discontiguous-io.cpp:75:13: error: ‘p’ does not name a type for (auto p = m_v.begin(); p != m_v.end(); ++p) { ^ discontiguous-io.cpp:75:30: error: expected ‘;’ before ‘p’ for (auto p = m_v.begin(); p != m_v.end(); ++p) { ^ discontiguous-io.cpp:75:30: error: ‘p’ was not declared in this scope discontiguous-io.cpp: In member function ‘std::ostream& iovec_t::write(std::ostream&) const’: discontiguous-io.cpp:87:8: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat] for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:87:13: error: ‘p’ does not name a type for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:87:30: error: expected ‘;’ before ‘p’ for (auto p = m_v.begin(); p != m_v.end(); ++p) ^ discontiguous-io.cpp:87:30: error: ‘p’ was not declared in this scope discontiguous-io.cpp: In function ‘void dumphex(std::ostream&, const void*, size_t)’: discontiguous-io.cpp:105:10: error: ‘uintptr_t’ was not declared in this scope << (uintptr_t)a + i << ':'; ^ discontiguous-io.cpp:105:20: error: expected ‘;’ before ‘a’ << (uintptr_t)a + i << ':'; ^ discontiguous-io.cpp:110:22: error: ‘uint8_t’ was not declared in this scope << (unsigned)((uint8_t*)a)[j]; ^ discontiguous-io.cpp:110:30: error: expected primary-expression before ‘)’ token << (unsigned)((uint8_t*)a)[j]; ^ discontiguous-io.cpp:110:31: error: expected ‘)’ before ‘a’ << (unsigned)((uint8_t*)a)[j]; ^ discontiguous-io.cpp:114:24: error: ‘uint8_t’ was not declared in this scope unsigned char c = ((uint8_t*)a)[j]; ^ discontiguous-io.cpp:114:32: error: expected primary-expression before ‘)’ token unsigned char c = ((uint8_t*)a)[j]; ^ discontiguous-io.cpp:114:33: error: expected ‘)’ before ‘a’ unsigned char c = ((uint8_t*)a)[j]; ^ discontiguous-io.cpp: At global scope: discontiguous-io.cpp:101:13: warning: unused parameter ‘a’ [-Wunused-parameter] static void dumphex(std::ostream &os, const void *a, size_t len) ^ discontiguous-io.cpp:126:51: error: ‘uint32_t’ has not been declared static ssize_t sg_read(const file_descriptor &fd, uint32_t lba, ^ discontiguous-io.cpp: In function ‘ssize_t sg_read(const file_descriptor&, int, const iovec_t&)’: discontiguous-io.cpp:143:2: error: ‘uint8_t’ was not declared in this scope uint8_t read6[6] = { ^ discontiguous-io.cpp:143:10: error: expected ‘;’ before ‘read6’ uint8_t read6[6] = { ^ discontiguous-io.cpp:153:11: error: ‘read6’ was not declared in this scope h.cmdp = read6; ^ discontiguous-io.cpp:163:54: error: ‘errno’ was not declared in this scope std::cerr << "READ(6) ioctl failed with errno " << errno ^ discontiguous-io.cpp:167:2: error: ‘uint32_t’ was not declared in this scope uint32_t result = h.status | (h.msg_status << 8) | ^ discontiguous-io.cpp:167:11: error: expected ‘;’ before ‘result’ uint32_t result = h.status | (h.msg_status << 8) | ^ discontiguous-io.cpp:169:6: error: ‘result’ was not declared in this scope if (result) { ^ discontiguous-io.cpp: At global scope: discontiguous-io.cpp:181:52: error: ‘uint32_t’ has not been declared static ssize_t sg_write(const file_descriptor &fd, uint32_t lba, ^ discontiguous-io.cpp: In function ‘ssize_t sg_write(const file_descriptor&, int, const iovec_t&)’: discontiguous-io.cpp:208:9: error: ‘errno’ was not declared in this scope << errno << '\n'; ^ discontiguous-io.cpp:217:2: error: ‘uint8_t’ was not declared in this scope uint8_t write6[6] = { ^ discontiguous-io.cpp:217:10: error: expected ‘;’ before ‘write6’ uint8_t write6[6] = { ^ discontiguous-io.cpp:227:11: error: ‘write6’ was not declared in this scope h.cmdp = write6; ^ discontiguous-io.cpp:237:55: error: ‘errno’ was not declared in this scope std::cerr << "WRITE(6) ioctl failed with errno " << errno ^ discontiguous-io.cpp:241:2: error: ‘uint32_t’ was not declared in this scope uint32_t result = h.status | (h.msg_status << 8) | ^ discontiguous-io.cpp:241:11: error: expected ‘;’ before ‘result’ uint32_t result = h.status | (h.msg_status << 8) | ^ discontiguous-io.cpp:243:6: error: ‘result’ was not declared in this scope if (result) { ^ discontiguous-io.cpp: In function ‘int main(int, char**)’: discontiguous-io.cpp:263:2: error: ‘uint32_t’ was not declared in this scope uint32_t offs = 0; ^ discontiguous-io.cpp:263:11: error: expected ‘;’ before ‘offs’ uint32_t offs = 0; ^ discontiguous-io.cpp:266:14: error: ‘uint8_t’ was not declared in this scope std::vector<uint8_t> buf; ^ discontiguous-io.cpp:266:21: error: template argument 1 is invalid std::vector<uint8_t> buf; ^ discontiguous-io.cpp:266:21: error: template argument 2 is invalid discontiguous-io.cpp:266:26: error: invalid type in declaration before ‘;’ token std::vector<uint8_t> buf; ^ discontiguous-io.cpp:269:48: error: ‘EOF’ was not declared in this scope while ((c = getopt(argc, argv, "hl:o:sw")) != EOF) { ^ discontiguous-io.cpp:271:42: error: ‘strtoul’ was not declared in this scope case 'l': len = strtoul(optarg, NULL, 0); break; ^ discontiguous-io.cpp:272:13: error: ‘offs’ was not declared in this scope case 'o': offs = strtoul(optarg, NULL, 0); break; ^ discontiguous-io.cpp:285:6: error: request for member ‘resize’ in ‘buf’, which is of non-class type ‘int’ buf.resize(len); ^ discontiguous-io.cpp:297:7: error: ‘offs’ was not declared in this scope if (offs % block_size) { ^ discontiguous-io.cpp:303:8: error: request for member ‘resize’ in ‘buf’, which is of non-class type ‘int’ buf.resize(buf.size() * 2); ^ discontiguous-io.cpp:303:19: error: request for member ‘size’ in ‘buf’, which is of non-class type ‘int’ buf.resize(buf.size() * 2); ^ discontiguous-io.cpp:304:29: error: request for member ‘begin’ in ‘buf’, which is of non-class type ‘int’ unsigned char *p = &*buf.begin(); ^ discontiguous-io.cpp:309:21: error: request for member ‘begin’ in ‘buf’, which is of non-class type ‘int’ iov.append(&*buf.begin(), buf.size()); ^ discontiguous-io.cpp:309:34: error: request for member ‘size’ in ‘buf’, which is of non-class type ‘int’ iov.append(&*buf.begin(), buf.size()); ^ discontiguous-io.cpp:322:31: error: ‘offs’ was not declared in this scope ssize_t len = sg_write(fd, offs / block_size, iov); ^ discontiguous-io.cpp:328:30: error: ‘offs’ was not declared in this scope ssize_t len = sg_read(fd, offs / block_size, iov); ^ make[1]: *** [discontiguous-io] Error 1 make[1]: Leaving directory/mnt/tests/kernel/storage/SSD/nvme_blktest/blktests/src' make: *** [all] Error 2

yizhanglinux commented 6 years ago

Here is the readable log: https://pastebin.com/5SEaWkp3

bvanassche commented 6 years ago

Which version of g++ are you using? Can you provide the output of g++ -v? Can you try to add -std=c++11 to CXXFLAGS in src/Makefile and rerun "make"?

yizhanglinux commented 6 years ago

Hi Bart Here is the g++ version, and it works now after add -std=c++11, thanks.

g++ -v

Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)

[root@storageqe-62 blktests]# git diff diff --git a/src/Makefile b/src/Makefile index da6b7ef..0b43495 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,7 +12,7 @@ CXX_TARGETS := \ TARGETS := $(C_TARGETS) $(CXX_TARGETS)

CFLAGS := -O2 -Wall -CXXFLAGS := -O2 -Wall -Wextra -Wno-sign-compare -Werror +CXXFLAGS := -O2 -Wall -Wextra -Wno-sign-compare -Werror -std=c++11

all: $(TARGETS)

[root@storageqe-62 blktests]# make make -C src all make[1]: Entering directory /mnt/tests/kernel/storage/SSD/nvme_blktest/blktests/src' cc -O2 -Wall -o loblksize loblksize.c cc -O2 -Wall -o loop_get_status_null loop_get_status_null.c cc -O2 -Wall -o openclose openclose.c cc -O2 -Wall -o sg/dxfer-from-dev sg/dxfer-from-dev.c cc -O2 -Wall -o sg/syzkaller1 sg/syzkaller1.c cc -O2 -Wall -o nbdsetsize nbdsetsize.c g++ -O2 -Wall -Wextra -Wno-sign-compare -Werror -std=c++11 -o discontiguous-io discontiguous-io.cpp make[1]: Leaving directory/mnt/tests/kernel/storage/SSD/nvme_blktest/blktests/src'

Thanks Yi