unable to use inline in declaration get error C2054

c

Solution

Use `__inline` with MSVC.

`inline` is a c99 keyword and c99 is not yet (fully) supported with MSVC.

"The inline keyword is available only in C++. The __inline and __forceinline keywords are available in both C and C++. For compatibility with previous versions, _inline is a synonym for __inline."

Source: http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx

Example

#if !defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER < 1900
#  define inline __inline
#endif

Note that `1900` means Visual-studio-2015, I mean, said version supports inline in .c files (so c99 standard is little more supported, but not fully).

Problem

I'm trying to compile some open source projects using the vs2013 c/c++ compiler. The file is .c extension. The below code returns some errors (below). All of which can be "fixed" by simply removing the inline in the declaration. Note: not a real function, just illustrative ``` static inline int pthread_fetch_and_add(int *val, int add, int *mutex) { return 0; } ``` errors error C2054: expected '(' to follow 'inline' error C2085: 'pthread_fetch_and_add' : not in formal parameter list error C2143: syntax error : missing ';' before '{'

Original source