cstack / db_tutorial

Writing a sqlite clone from scratch in C

Home Page:https://cstack.github.io/db_tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

initializer element is not constant

tcstory opened this issue · comments

environment: ubuntu 18.04 ,gcc version 7.3.0

I had finished the part 3, but when i compile the source code, it reports the following two type errors:

(1) variably modified ‘username’ at file scope
char username[COLUMN_USERNAME_SIZE];

(2) initializer element is not constant
const uint32_t USERNAME_OFFSET = ID_OFFSET + ID_SIZE;

I had google the problem,one question at stackoverflow say that this is because the const just means "read only" not a real constant.

I'm very interested in how can you compile the code successfully.

@tcstory What is the full error that you are seeing ? Also, paste the relevant code around the error.

@ashishnegi this is the partial errors

deepinscrot-1153

@tcstory How is ID_OFFSET defined ?

Also, username should be within a struct
Instructions to build the code is in Makefile

@tcstory
This issue has been solved by issues/17.

@zhazhalaila i know change "const" to "define" will solve the problem, i just curious about how the author complie the code without any error.

@tcstory Hi! I developed this on a mac, so it's possible some code worked for me that didn't work for you. Any contributions that make the code more portable are welcome!