I was working on a practice code, but meet the errors like below:
1. Env
- OS:
Ubuntu 18.04 x64 - Build Tools:
apt install build-essential cmake -y
2. Code
filename: repl.c
#include <stdint.h>
...
const uint32_t PAGE_SIZE = 4096; // 4*1024 bytes
#define TABLE_MAX_PAGES 100
const uint32_t ROWS_PER_PAGE = PAGE_SIZE / ROW_SIZE;
const uint32_t TABLE_MAX_ROWS = ROWS_PER_PAGE * TABLE_MAX_PAGES;
...
3. CMakefile
filename: CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(SQLITE_CLONE)
add_executable(a.out repl.c)
4. Reproduction of the error
Try to build:
cmake .
make
But get error like:
/home/ws/sqlite_clone_in_c/P3/repl.c:157:32: error: initializer element is not constant
const uint32_t ROWS_PER_PAGE = PAGE_SIZE / ROW_SIZE;
^~~~~~~~~
/home/ws/sqlite_clone_in_c/P3/repl.c:158:33: error: initializer element is not constant
const uint32_t TABLE_MAX_ROWS = ROWS_PER_PAGE * TABLE_MAX_PAGES;