While GCC allows it:
It is non standard:
The C standard does not allow void pointer arithmetic. However, GNU C is allowed by considering the size of void is 1.
C11 standard §6.2.5
Paragraph - 19
The void type comprises an empty set of values; it is an incomplete object type that cannot be completed.
Errors:
In file included from /home/maurice/source/cFS/apps/sbn/fsw/src/sbn_app.c:27:0:
cFS/apps/sbn/fsw/src/sbn_pack.h: In function "Pack_Data":
cFS/apps/sbn/fsw/src/sbn_pack.h:41:25: error: pointer of type "void *" used in arithmetic [-Werror=pointer-arith]
memcpy(PackPtr->Buf + PackPtr->BufUsed, DataBuf, DataBufSz);
cFS/apps/sbn/fsw/src/sbn_pack.h: In function "Unpack_Data":
cFS/apps/sbn/fsw/src/sbn_pack.h:102:33: error: pointer of type "void *" used in arithmetic [-Werror=pointer-arith]
memcpy(DataBuf, Unpack->Buf + Unpack->Curr, Sz);
cFS/apps/sbn/fsw/src/sbn_app.c: In function "SBN_PackMsg":
cFS/apps/sbn/fsw/src/sbn_app.c:134:26: error: pointer of type "void *" used in arithmetic [-Werror=pointer-arith]
SwapCCSDS(SBNBuf + SBN_PACKED_HDR_SZ);
Used an example arch_build_custom.cmake
add_compile_options(
-std=c99 # Target the C99 standard (without gcc extensions)
-pedantic # Issue all the warnings demanded by strict ISO C
-Wall # Warn about most questionable operations
-Wstrict-prototypes # Warn about missing prototypes
-Wwrite-strings # Warn if not treating string literals as "const"
-Wpointer-arith # Warn about suspicious pointer operations
-Wcast-align # Warn about casts that increase alignment requirements
-Werror # Treat warnings as errors (code should be clean)
-Wno-error=unused-but-set-variable
-Wno-error=discarded-qualifiers
)
Fix is to fix the type of Buf from void to uint8 or remove the -Werror statement
Reporter Info
Maurice Smulders, Geneva Technologies Inc
While GCC allows it: It is non standard: The C standard does not allow void pointer arithmetic. However, GNU C is allowed by considering the size of void is 1.
C11 standard §6.2.5
Paragraph - 19
Errors:
Used an example arch_build_custom.cmake
Fix is to fix the type of Buf from void to uint8 or remove the -Werror statement
Reporter Info Maurice Smulders, Geneva Technologies Inc