cJSON - undefined reference to __isnan

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

cJSON - undefined reference to __isnan

ソリューションへジャンプ
6,452件の閲覧回数
nickwallis
Senior Contributor I

Hi,

I am using cJSON is a project but am having an issue building it that I don't understand.

If I include references to cJSON_Print(), then the build fails with an error message "undefined reference to __isnan". This is despite the fact that this is available to the build, in math.h (which is #included).

Why would the build fail in this way, even though the required definition/file is actually there?

thanks

-Nick

 

0 件の賞賛
返信
1 解決策
6,392件の閲覧回数
nickwallis
Senior Contributor I

I got some time to look into this, and on second glance it seemed obvious that Redlib was missing these dependencies, and changing to Newlib has fixed this. Thanks.

元の投稿で解決策を見る

0 件の賞賛
返信
4 返答(返信)
6,393件の閲覧回数
nickwallis
Senior Contributor I

I got some time to look into this, and on second glance it seemed obvious that Redlib was missing these dependencies, and changing to Newlib has fixed this. Thanks.

0 件の賞賛
返信
6,445件の閲覧回数
converse
Senior Contributor V

The error is for __isnand not isnan...

0 件の賞賛
返信
6,441件の閲覧回数
nickwallis
Senior Contributor I

Exactly my point. The error message does not match the code.

Here is the code:

/* Render the number nicely from the given item into a string. */
static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer)
{
    unsigned char *output_pointer = NULL;
    double d = item->valuedouble;
    int length = 0;
    size_t i = 0;
    unsigned char number_buffer[26] = {0}; /* temporary buffer to print the number into */
    unsigned char decimal_point = get_decimal_point();
    double test = 0.0;

    if (output_buffer == NULL)
    {
        return false;
    }

    /* This checks for NaN and Infinity */

    if (isnan(d) || isinf(d))
    {
        length = sprintf((char*)number_buffer, "null");
    }
    else
    { ..........

And here is the compiler error:

C:\mcuxpresso_workspace\sdm_01\Debug/../source/cJSON.c:562: undefined reference to `__isnand'

If I CTRL-click on the isnan in the code, then it takes me to the definition in math.h as expected.

So, why the compiler error? The code looks OK to me.

Thanks,

-Nick

0 件の賞賛
返信
6,437件の閲覧回数
converse
Senior Contributor V

Just to clarify. It is a linker error not a compiler error. That is, you are missing a library. You need to provide a library to satisfy the isnand function 

0 件の賞賛
返信