LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-10-2006, 10:36 AM   #1
lloydie-t
LQ Newbie
 
Registered: Mar 2006
Location: UK
Distribution: Redhat
Posts: 5

Rep: Reputation: 0
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?
 
Old 09-10-2006, 01:27 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082Reputation: 2082
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;
 
Old 09-11-2006, 01:47 PM   #3
lloydie-t
LQ Newbie
 
Registered: Mar 2006
Location: UK
Distribution: Redhat
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Argument 2 - Pointer Error ?? Easy Fix?? Mistro116@yahoo.com Programming 1 10-04-2005 07:04 AM
returning data to main() via a pointer to a pointer. slzckboy Programming 3 05-30-2005 01:20 PM
Function Pointer as an Argument in C trutnev Programming 5 05-24-2005 10:22 AM
hot to set value of pointer to pointer to a structure in C alix123 Programming 2 11-17-2004 06:40 AM
passing function pointer as argument worldmagic Programming 7 08-04-2004 03:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration