tags:

views:

237

answers:

3

I have a RefTables.pc file.

when i type make command.

This is my warning.

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'

How i can remove it.

i am using linux & gcc compiler.

+1  A: 

You can remove the warning by specifying the type of the 5 offending declarations. Actually, they must be declared with no type at all, which defaults to int in C (but generates a warning).

Edit: I found on Google this declaration.

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

The function has no return type. It should have one. Write it as follows.

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

Or you can manually state in the compiler command line to ignore these warnings. They won't be displayed anymore.

Didier Trosset
how i can remove the warning.will you describe more.
ambika
A: 

In the future, provide a code snippet along with the warnings so that we have some context to work from. Otherwise we can only guess at what the real problem is.

I'm assuming that sqlcxt, sqlcx2t, etc., are functions. Without seeing the source code, it sounds like you don't have a declaration for those functions in scope before using them.

Here's a short example of what I mean:

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

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

When the compiler sees the call to foo in main, it doesn't have a declaration in scope, so it assumes that foo returns int, not void, and will return a warning similar to what you got above.

If your functions are defined in the same file as they are called, there are two ways around this problem. My preferred way is to define the function before it is used:

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

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

Another way is to have a declaration of the function in scope before calling it:

void foo(void);

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

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

It sounds like these functions are part of a database API; if so, there should be a header file that contains declarations for those functions, and that header should be included in your source file:

/** 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 */

Hope that helps.

John Bode
A: 

It's been a while since I used Pro*C, but I think you can add a command line option to the proc command line

code=ANSI_C

which will give prototypes for the functions named.

Simon Nickerson
ambika
What is the command to produce .c files from .pc files in your makefile?
Simon Nickerson