I am just getting started with Solana development. I am a C programmer so I am most comfortable with C. I am just using the most basic code to create a shared object file. I am on Ubuntu 22 x86-64. The clang version being used seems to be:
clang version 17.0.6 (https://github.com/anza-xyz/llvm-project.git 9003b439a0407ff1c1b06b52ffb4809bfb3ccff4)Target: x86_64-unknown-linux-gnuThread model: posixInstalledDir: /home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/../dependencies/platform-tools/llvm/bin
My C file is:
#include "solana_sdk.h"extern uint64_t entrypoint(const uint8_t *input){ if (input == NULL) { return -1; } return 0;}
Here is my Makefile at the top of the repo:
OUT_DIR := ./buildINC_DIRS := /home/user/dev/solana/sdk/sbf/c/incinclude ~/.local/share/solana/install/active_release/bin/sdk/sbf/c/sbf.mk
Here, ~/dev/solana is the solana git repository.make V=1
shows the following build command:
mkdir -p ./build/program//home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/../dependencies/platform-tools/llvm/bin/clang -Werror -O2 -fno-builtin -std=c17 -isystem/home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/inc -isystem/home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/../dependencies/platform-tools/llvm/lib/clang/17/include -I/home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/../dependencies/platform-tools/llvm/include -I/home/user/dev/solana/sdk/sbf/c/inc -target sbf -fPIC -o ./build/program/program.o -c ./src/program/program.c
It makes sense that c17 standard is being used since it is in the sbf.mk makefile include. However, I get the following build error:
In file included from ./src/program/program:1:In file included from /home/user/dev/solana/sdk/sbf/c/inc/solana_sdk.h:6:In file included from /home/user/dev/solana/sdk/sbf/c/inc/sol/assert.h:6:/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:39:34: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 39 | static_assert(sizeof(int8_t) == 1); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:40:35: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 40 | static_assert(sizeof(uint8_t) == 1); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:41:35: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 41 | static_assert(sizeof(int16_t) == 2); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:42:36: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 42 | static_assert(sizeof(uint16_t) == 2); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:43:35: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 43 | static_assert(sizeof(int32_t) == 4); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:44:36: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 44 | static_assert(sizeof(uint32_t) == 4); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:45:35: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 45 | static_assert(sizeof(int64_t) == 8); | ^ | , ""/home/user/dev/solana/sdk/sbf/c/inc/sol/types.h:46:36: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions] 46 | static_assert(sizeof(uint64_t) == 8); | ^ | , ""8 errors generated.make: *** [/home/user/.local/share/solana/install/active_release/bin/sdk/sbf/c/sbf.mk:263: build/program/program] Error 1
I am confused why the static asserts from the sdk in the solana repo would not be consistent with the C-standard mandated in the sbf.mk file. Am I doing something wrong? What is the solution? I would prefer not to edit the sbf.mk file or the solana sdk header files, since I like to obey proper ownership. Thank you very much.