Skip to content

cJSON fails to build with default __stdcall calling convention (/Gz) on Windows #296

@zhindes

Description

@zhindes

This is because malloc, free, and realloc are explicitly __cdecl regardless of the default calling convention. Here are some example errors:

cJSON\cJSON.c(175): error C2440: '=': cannot convert from 'void *(__cdecl *)(std::size_t)' to 'void *(__stdcall *)(std::size_t)'
cJSON\cJSON.c(176): error C2440: '=': cannot convert from 'void (__cdecl *)(void *)' to 'void (__stdcall *)(void *)'
cJSON\cJSON.c(177): error C2440: '=': cannot convert from 'void *(__cdecl *)(void *,std::size_t)' to 'void *(__stdcall *)(void *,std::size_t)'
cJSON\cJSON.c(181): error C2440: '=': cannot convert from 'void *(__cdecl *)(std::size_t)' to 'void *(__stdcall *)(std::size_t)'
cJSON\cJSON.c(187): error C2440: '=': cannot convert from 'void (__cdecl *)(void *)' to 'void (__stdcall *)(void *)'
cJSON\cJSON.c(195): error C2440: '==': cannot convert from 'void *(__cdecl *)(std::size_t)' to 'void *(__stdcall *)(std::size_t)'
cJSON\cJSON.c(195): error C2440: '==': cannot convert from 'void (__cdecl *)(void *)' to 'void (__stdcall *)(void *)'
cJSON\cJSON.c(197): error C2440: '=': cannot convert from 'void *(__cdecl *)(void *,std::size_t)' to 'void *(__stdcall *)(void *,std::size_t)'

I have submitted a pull request that fixes the issues here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions