2010-03-09 91 views
1

我有一个RefTables.pc文件。C .pc文件警告

当我执行命令make,我得到这样的警告:

RefTables.c:109: warning: type defaults to `int' in declaration of `sqlcxt' 
RefTables.c:111: warning: type defaults to `int' in declaration of `sqlcx2t' 
RefTables.c:113: warning: type defaults to `int' in declaration of `sqlbuft' 
RefTables.c:114: warning: type defaults to `int' in declaration of `sqlgs2t' 
RefTables.c:115: warning: type defaults to `int' in declaration of `sqlorat' 

如何删除呢?

我正在使用linux & gcc编译器。

回答

1

您可以通过指定5个违规声明的类型来删除警告。实际上,它们必须声明为无类型,默认为C中的int(但会生成警告)。

编辑:我在Google上找到了这个声明。

extern sqlcxt (/*_ void **, unsigned int *, struct sqlexd *, struct sqlcxp * _*/); 

函数没有返回类型。它应该有一个。写下如下。

extern int sqlcxt (/*_ void **, unsigned int *, struct sqlexd *, struct sqlcxp * _*/); 

或者您可以在编译器命令行中手动声明忽略这些警告。他们将不会再显示。

+0

我如何删除警告。你会更详细地描述 。 – ambika 2010-03-09 12:35:51

0

将来,请提供一段代码和警告,以便我们有一些上下文可供使用。否则,我们只能猜测真正的问题是什么。

我假设sqlcxt,sqlcx2t等是函数。在没有看到源代码的情况下,它听起来像是在使用它们之前没有为这些函数声明这些函数。

这里是什么,我的意思是一个简单的例子:

int main(void) 
{ 
    foo(); 
    return 0; 
} 

void foo(void) 
{ 
    // do something interesting 
} 

当编译器看到在main调用foo,它没有范围的声明,所以它假定foo返回int,而不是无效,并会返回类似于上面得到的警告。

如果你的函数被定义在它们被调用的同一个文件中,解决这个问题的方法有两种。我的首选方法是定义功能在使用前:

void foo(void) 
{ 
    // do something interesting 
} 

int main(void) 
{ 
    foo(); 
    return 0; 
} 

另一种方法是调用它之前在范围函数的声明:

void foo(void); 

int main(void) 
{ 
    foo(); 
    return 0; 
} 

void foo(void) 
{ 
    // do something interesting 
} 

这听起来像这些功能的一部分的数据库API;如果是的话,应该有一个包含这些函数的声明头文件,并且头部应包含在源文件:

/** foo.c */ 
#include "foo.h" 

void foo(void) 
{ 
    // do something interesting 
} 
/** end foo.c */ 

/** foo.h */ 
#ifndef FOO_H 
#define FOO_H 

void foo(void); 

#endif 
/** end foo.h */ 

/** main.c */ 
#include "foo.h" 

int main(void) 
{ 
    foo(); 
    return 0; 
} 
/** end main.c */ 

希望有所帮助。

1

这已经有一段时间,因为我使用了Pro * C,但我认为你可以在命令行选项添加到proc命令行

code=ANSI_C 

,这将给名为函数的原型。

+0

感谢您的建议。 但我用Makefile&make命令来编译。 我如何使用proc命令。 – ambika 2010-03-11 05:17:46

+0

什么是生成文件中的.pc文件生成.c文件的命令? – 2010-03-11 08:04:52