antirez / sds

Simple Dynamic Strings library for C
BSD 2-Clause "Simplified" License
4.89k stars 473 forks source link

Question, why in sds.h you have (static inline functions)? #85

Open topilski opened 7 years ago

topilski commented 7 years ago

Hi, why in sds.h you have (static inline functions)? Also why sdshdr placed in header? I try to link sds.h into C++ project with -Wpedantic flag and receive errors like "warning: ISO C++ forbids zero-size array in sdshdr structs".

Kredns commented 7 years ago

@topilski The most likely reason the functions are made static inline is for performance reasons. See this answer on StackOverflow for more specifics..

Why are you trying to use this library in a C++ project when C++ already has std::string which does a pretty good job at providing strings.

topilski commented 7 years ago

I using sds for parsing command line, i like how it done in sds. About inline functions (compiler to attempt to embed the function), inline only suggestion for compiler, need to disassemble code and after that talk about applying of inlining.