none
a calling convention may not be followed by a nested declarator RRS feed

  • Question

  • Hi all, I'm  newby in visual studio and in c developement.

    I can't compile a project with the error  in the subject (IntelliSense told me ).

    In the file myfile.h there's this definition 

    #define nearbyint(x)  ((ssize_t) ((x)+0.5))

    And in the file math.h (here is the compiler error, syntax error: '(') there's the reference to this definition

    _CRTIMP double __cdecl nearbyint(_In_ double _X);

    I can't figure out the problem.

    Thank you a lot

    Luca

    • Moved by Amanda Zhu Wednesday, September 25, 2013 5:48 AM
    Tuesday, September 24, 2013 1:37 PM

Answers

  • There's already a C standard function named nearbyint. Your macro interferes with that, try changing your macro name. You could also try to move the macro so it is defined after all C runtime headers are included but renaming is a better choice.
    • Proposed as answer by Jane Wang - MSFT Wednesday, September 25, 2013 8:38 AM
    • Marked as answer by Luca newbie Wednesday, September 25, 2013 8:39 AM
    Wednesday, September 25, 2013 5:59 AM
    Moderator

All replies

  • Hello,

    I have moved this thread to Visual C++ forum for better response.

    Thanks,


    Amanda Zhu <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 25, 2013 5:49 AM
  • There's already a C standard function named nearbyint. Your macro interferes with that, try changing your macro name. You could also try to move the macro so it is defined after all C runtime headers are included but renaming is a better choice.
    • Proposed as answer by Jane Wang - MSFT Wednesday, September 25, 2013 8:38 AM
    • Marked as answer by Luca newbie Wednesday, September 25, 2013 8:39 AM
    Wednesday, September 25, 2013 5:59 AM
    Moderator
  • I renamed the macro and now all works fine.

    Thank you

    Luca

    Wednesday, September 25, 2013 7:15 AM
  • I renamed the macro and now all works fine.

    Why not get rid of the macro and use the version in math.h?

    Also, what is your function supposed to do for negative x?

    Also, isn't there a typo in your macro (size_t -> ssize_t)?


    David Wilkinson | Visual C++ MVP

    Wednesday, September 25, 2013 10:50 AM
  • ssize_t is correct as written. It's a signed integral type with the same number of bits as size_t (which is unsigned).

    Igor Tandetnik

    Wednesday, September 25, 2013 12:48 PM
  • ssize_t is correct as written. It's a signed integral type with the same number of bits as size_t (which is unsigned).

    Igor Tandetnik


    Learn something every day! Nevertheless, I think the macro is not correctly written for negative x.

    David Wilkinson | Visual C++ MVP

    Wednesday, September 25, 2013 1:34 PM