LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   format argument is not a pointer (https://www.linuxquestions.org/questions/programming-9/format-argument-is-not-a-pointer-482132/)

lloydie-t 09-10-2006 10:36 AM

format argument is not a pointer
 
Although I no nothing about C++ I am trying to edit a program so that it adds a record to a sqlite database. I am getting a few warnings and errors which stops it compiling. So I need a little help fixing it
errors:
PHP Code:

makeWarningFile `logger.cpp' has modification time 45 s in the future
g++  -c -Wall -O -g logger.cpp -o logger.o
logger.cpp: In function 
`voidstart_one_channel(void*)':
logger.cpp:607: warning: format argument is not a pointer (arg 6)
logger.cpp:629: error: jump to case label
logger.cpp:603: error:   crosses initialization of `char*zErrMsg'
make: *** [logger.oError 1 

code sample:
PHP Code:

        char *zErrMsg 0//line 603
        
char sql[200];
        
int rc;
        
sqlite3 *db;
        
sprintf(sql"insert into call_data (direction, call_time, dest, trunk_no, file_name)values('%s','%s','%s','%s','%s')"details.inoutdetails.statime,details.cidn,channel,details.filename); //line 607
        
rc sqlite3_open("/var/tmp/logger/database/logger.db", &db);
        
rc sqlite3_exec(dbsqlNULL0, &zErrMsg);
        if( 
rc!=SQLITE_OK ){
        
//fprintf(stderr, "SQL error: %s\n", zErrMsg);
        
sqlite3_free(zErrMsg);
        }
        
sqlite3_close(db);
        
LOGIT("[%02d] sql string = %s\n",channel,sql);


                        
// Clear out details ready for next call
                        
details.inout[0] = 0;
                        
details.filename[0] = 0;
                        
details.statime[0] = 0;
                        
details.endtime[0] = 0;
                        
details.cidn[0] = 0;
                        
details.cidt[0] = 0;
                        
strcpy(details.term"");
            break;
                        
                        default:        
// Any thing else ?? line 629
                        
break;

                    }
                    break; 

Any ideas?

ntubski 09-10-2006 01:27 PM

logger.cpp:607: warning: format argument is not a pointer (arg 6)
This refers the the variable channel, which apparently is not a char* (pointer to char, the standard c-string). The answer might be to put &channel instead, but you'll have to post the declaration of channel otherwise I can't tell.

logger.cpp:629: error: jump to case label
logger.cpp:603: error: crosses initialization of `char*zErrMsg'

I think the solution here is to enclose everything from case lable to the break in curly braces. That is, scrolling up from line 603 look for a line with
Code:

case SOMETHING:
put a { after the colon, add a } before the break here:
Code:

                        strcpy(details.term, "");
            }
            break;


lloydie-t 09-11-2006 01:47 PM

Thanks I sorted that out only to be confronted by another problem. I think it has something to do with linker or LD but I am not sure. Any Ideas?
Code:

/usr/src/logger-1.2-beta3/src/logger.cpp:731: undefined reference to `sqlite3_open'
logger.o(.text+0xc99):/usr/src/logger-1.2-beta3/src/logger.cpp:732: undefined reference to `sqlite3_exec'
logger.o(.text+0xcae):/usr/src/logger-1.2-beta3/src/logger.cpp:735: undefined reference to `sqlite3_free'
logger.o(.text+0xcbf):/usr/src/logger-1.2-beta3/src/logger.cpp:737: undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
make: *** [logger] Error 1

Lloydie T


All times are GMT -5. The time now is 11:58 AM.