称为对象类型' int'不是xcode中的函数或函数指针

时间:2014-10-11 12:17:51

标签: c xcode

我已经创建了以下宏

#define log printf("(%s):(%d)  ",__FUNCTION__, __LINE__);printf

我在主要功能中使用它来记录

log("Hello world\n"); 

导致运行时错误,因为" lldb "。 IDE中的错误显示"称为对象类型' int'不是x代码中的函数或函数指针"

2 个答案:

答案 0 :(得分:3)

尝试:

#define LOG( s ) printf( "(%s):(%d)%s\n", __FUNCTION__, __LINE__, s );

答案 1 :(得分:1)

当你说“如果我给出论证失败”时,你可能想要这样的东西:

#include <stdio.h>

#define LOG( FormatString, ... ) printf( "(%s:%d)" FormatString "\n", __FUNCTION__, __LINE__, __VA_ARGS__ )

int main(int argc, const char * argv[])
{
    int i = 16;

    LOG( "i = %d", i );

    LOG( "Hello World", NULL );

    return 0;
}