Help - Cast converts default int return type


 
Thread Tools Search this Thread
Top Forums Programming Help - Cast converts default int return type
# 1  
Old 04-23-2007
Data Help - Cast converts default int return type

What does the warning message 724 "Cast converts default int return type to." tell me.

I am new to C. (used it some in college). We are migrating our c-code to 10.2.0.3.0. The programs compiled clean. However there were several warning messages that kick out. The most prominent warning is:

Pro*C/C++: Release 10.2.0.3.0 - Production on Mon Apr 23 09:47:08 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
System default option values taken from: /u21/oracle/product/102030_64/precomp/g
cc -DCACS_ORA -O -g -DDEBUG +DA2.0W +DS2.0 -DSS_64BIT_SERVER -I. -Ic
cc: "drmio.pc", line 86: warning 724: Cast converts default int return type to .
cc: "drmio.pc", line 825: warning 724: Cast converts default int return type to.


I believe it is a 32 bit -> 64 bit issue. (pointers are now 64 bits)

Any assistance that can be provided would be greatly appreciated. Thank you

Below is a snipit of line 86 with declarations:

#include <stdio.h>

#include "drm.h"
/*VA-28 - 07/25/01 - Begin*/
/*-- modify for the cache --*/
#include "drm_mods.h"
/*VA-28 - 07/25/01 - End*/

#define IsItNullColumn(column_name) (column_name == -1)
#define AssignNullStr(char_array) strcpy(char_array,"")

#define SQL_NO_ERROR 0
#define SQL_NOT_FOUND +100

EXEC SQL INCLUDE SQLCA ;

TEMPLATE_ELEMENT *gstr_db_element = NULL ;
OLD_DOC_ELEMENT *gstr_olddoc_element = NULL ;
int gai_element_array[SIZE_MAX_NO_OF_ELEMENTS] ;

int gi_max_database_elements = 0 ;
int gi_max_olddoc_elements = 0 ;

extern int gi_max_elements ;
int gi_max_elements ;

char gac_default_unix_date_format[] = "%D %T" ;

int GetElementInfo_i(int ar_ai_element_id[] )
{
/*VA-28 - 07/25/01 - Begin*/
/*--
EXEC SQL BEGIN DECLARE SECTION ;
int li_id ;
int li_retrieval_type ;
int li_criteria_id ;
char lac_table_name[SIZE_TBL_NAME] ;
EXEC SQL VAR lac_table_name is STRING(SIZE_TBL_NAME);
char lac_fld_name[SIZE_FLD_NAME] ;
EXEC SQL VAR lac_fld_name is STRING(SIZE_FLD_NAME);
char lac_fun_name[SIZE_FUNC_NAME] ;
EXEC SQL VAR lac_fun_name is STRING(SIZE_FUNC_NAME);
int li_format_fun_id ;
char lac_word_format[SIZE_FORMAT] ;
EXEC SQL VAR lac_word_format is STRING(SIZE_FORMAT);

short lshort_criteria_null_ind,
lshort_tablename_null_ind,
lshort_fldname_null_ind,
lshort_funname_null_ind,
lshort_formatfun_null_ind,
lshort_wordformat_null_ind ;

--*/
/*-- EXEC SQL END DECLARE SECTION ;--*/
/*VA-28 - 07/25/01 - End*/

int count = 0 ;
/*VA-28 - 07/25/01 - Begin*/
int i = 0;
int li_id;

/*-- [ARCS Mods] Debug Messages --*/
DebugPrintf("In GetElementInfo_i()\n");
DebugPrintf("gi_max_elements = %d\n", gi_max_elements);
DebugPrintf("g_max_cache_db_elements = %d\n", g_max_cache_db_elements);
/*VA-28 - 07/25/01 - End*/

if ( gi_max_elements <= 0 )
{
return(-1) ;
}
gi_max_database_elements = gi_max_elements ;

gstr_db_element = (TEMPLATE_ELEMENT *)DoMemoryAlloc_pv(gi_max_elements * sizeof(TEMPLATE_ELEMENT)) ; (line 86)

if ( gstr_db_element == (TEMPLATE_ELEMENT *)NULL )
{
return(-1) ;
}

Last edited by rtgreen; 04-24-2007 at 08:44 AM..
# 2  
Old 04-23-2007
Very often the line number is where the error was noticed, not where it occurred. I believe the message is complaining about the return(-1). That error message looks garbled, but probably I would check for a mismatch bewteen the declaracation of the function and what you are returning.
# 3  
Old 04-23-2007
You don't show what type the function is supposed to be returning. What type is the "return (-1);" supposed to be returning. If it's not some kind of int or float you are in trouble.

eg

void *func(void)
{
return -1;
}

is an error, where as

int func(void)
{
return -1;
}

is not.
# 4  
Old 04-24-2007
Thank for the reply. I checked and the function returns int. I've also included the code from the building of the script. If you could look at it one more time, I'd appreciate it.

Per your suggestion, I noticed that a function in many of my bad calls returns a void.

DoMemoryAlloc_pv (line 86) is defined with a void pointer (see below). The documentation tells me that in C++ I need to cast it. Can I still use a void in this definition? Do I have to determine the type before I allocate memory?
Please help.

void *DoMemoryAlloc_pv(size_t memsize)
{
void * vp_tmp_memory_area ;

if (!(vp_tmp_memory_area = (void *)malloc(memsize)))
{
LogPrintf("Unable to allocate memory (requested memory size = %d bytes)\n", memsize) ;
return((void *)NULL) ;
}
return((void *)vp_tmp_memory_area) ;
}

Last edited by rtgreen; 04-24-2007 at 09:46 AM..
# 5  
Old 04-24-2007
You can use pointer to void as the value returned from a function. But you must cast it to use it. You can allocate a chunk of memory not knowing what will go there.

I can't really comment on the expanded code you added. I don't know what "EXEC SQL" is supposed to do. I'm guessing you have some database preprocessor or something. Also I don't have your include files. Just glancing at the code, I do not see a reason for a complaint about the returns.
# 6  
Old 04-24-2007
Thank you for all your help. I discovered that if I simply declare the definition of the function that is causing the error in the beginning of the code, the errors go away. I don't think the compiler was seeing the definition of the embedded function.

extern void *DoMemoryAlloc_pv(size_t) ;
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Struct as return type

Hello all, I am trying to define a function with return type as struct, but seem to be failing. Error I am receiving is following .CC error: prototype for 'RpcHOData L1ITMu::MBLTCollection::getUnassociatedHORpcClusters(double)' does not match any in class 'L1ITMu::MBLTCollection' struct... (1 Reply)
Discussion started by: emily
1 Replies

2. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

3. Shell Programming and Scripting

what is the default return type of localtime() in perl?

Hi, I have given like this to get the time of the sub routine. my $start = localtime(); print "\n start time: $start \n"; Output start time: Fri Apr 29 01:01:31 2011 I want to know what is the format of the time. I am not able to follow is is HH:MM:SS or MM:HH:SS os... (2 Replies)
Discussion started by: vanitham
2 Replies

4. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

5. Shell Programming and Scripting

Find command return type

Hi all does find command return anything if the file to be searched is not found? Like if I search from a file in a dir does it return false or null if the file is not found? Please suggests. (3 Replies)
Discussion started by: Veenak15
3 Replies

6. Programming

Need help in storing command line argument argv[2] to a variable of int type

The following program takes two command line arguments. I want the second argument (fileCount) to be stored/printed as a int value. I tried my best to typecast the char to int (check the printf statement at last) but is not working...the output is some junk value. This program is in its... (3 Replies)
Discussion started by: frozensmilz
3 Replies

7. Red Hat

cast from const void* to unsigned int loses precision

Hello everey one, here i am attempting to compile a c++ project .it's throughing the following errors. my machine details are as follows: Linux chmclozr0119 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux errors: ===== Generating... (0 Replies)
Discussion started by: mannam srinivas
0 Replies

8. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

9. Programming

Return value (int) from main to calling shell

What is the sytax to return an int from C program main back to calling shell? #!/usr/bin/ksh typeset -i NO_RECS $NO_RECS=process_file # Process file is a C program that is set up to return an int from main. The #program complies with no issues, but an error is generated when the... (3 Replies)
Discussion started by: flounder
3 Replies
Login or Register to Ask a Question