The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Looking for a command line tool that converts a .wmv file into .mpg karman OS X (Apple) 2 2 Weeks Ago 09:21 PM
OggConvert makes Ogg converts (and converts to Oggs) iBot UNIX and Linux RSS News 0 12-21-2007 02:00 PM
Type I and Type II Errors - The Heart of Event Processing iBot Complex Event Processing RSS News 0 12-05-2007 02:50 PM
Human readable type vs MIME type detection using file spauldingsmails Shell Programming and Scripting 0 03-21-2007 08:43 PM
why to use dynamic cast in c++ sarwan High Level Programming 0 09-01-2005 02:40 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-23-2007
Registered User
 

Join Date: Apr 2007
Posts: 3
Stumble this Post!
Unhappy 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 04:44 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-23-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,450
Stumble this Post!
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.
Reply With Quote
  #3 (permalink)  
Old 04-23-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Stumble this Post!
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.
Reply With Quote
  #4 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Apr 2007
Posts: 3
Stumble this Post!
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 05:46 AM.
Reply With Quote
  #5 (permalink)  
Old 04-24-2007
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,450
Stumble this Post!
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.
Reply With Quote
  #6 (permalink)  
Old 04-24-2007
Registered User
 

Join Date: Apr 2007
Posts: 3
Stumble this Post!
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) ;
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0