Page 1 of 1

vsprintf question

Posted: Sat May 28, 2011 5:56 am
by zx5000
I'm having trouble with vsprintf. Any tips would be appreciated.

Simple code (standard stuff)

Code: Select all

	
#include <stdio.h>             // gnu usual is stdarg.h but it's declared here instead

.
.
.

char vbuf[512];

    va_list argp;
    va_start(argp, fmt);
    vsprintf(vbuf, fmt, argp);
Produces the following build error:

Code: Select all

..\mcTalker.cpp:26: error: 'va_list' was not declared in this scope
..\mcTalker.cpp:26: error: expected `;' before 'argp'
..\mcTalker.cpp:27: error: 'argp' was not declared in this scope
..\mcTalker.cpp:27: error: 'va_start' was not declared in this scope

Re: vsprintf question

Posted: Sat May 28, 2011 6:39 pm
by greengene
i would suspect that your include path doesn't have everything
you need, i.e., the directory that has stdarg.h in it.
to verify, add
#include <stdarg.h>
and see if you get a complie error on not being able to find the file.
if so, then add that directory.

Re: vsprintf question

Posted: Fri Jun 03, 2011 7:42 am
by zx5000
There is no stdarg.h in the netburner environment and vsprintf is defined in stdio.h

I uninstalled and reinstalled the nndk. Are there extra components that must be downloaded separately?

thanks

Re: vsprintf question

Posted: Fri Jun 03, 2011 8:14 am
by Chris Ruff
I use

#include <stdarg.h>

// **||*************************************************************
//
// debug use only
//
void zprintf(char *fmt,...)
// **||*************************************************************
{
int i,j;
if (cZDebug)
{

va_list args;
char cBuf[100];
va_start(args,fmt);
vsprintf(cBuf,fmt,args);
va_end(args);

i = strlen(cBuf);
printf(cBuf);
}
}

in essentially every project I have.

I _do_ like the ...



stdarg is a part of the GCC compiler environment, not a part of NB library

Chris

Re: vsprintf question

Posted: Fri Jun 03, 2011 9:52 am
by zx5000
How do you get around the "Unresolved inclusion" error in the nbeclipse?

Re: vsprintf question

Posted: Fri Jun 03, 2011 10:01 am
by Chris Ruff
Ah, eclipse

I'm sorry, I don't use eclipse, but I am supposing that there is a menu entry for include subdirectories that you would specify:

\nburn\gcc-m68k\lib\gcc\m68k-elf\4.2.1\include

or the other c++ path where it is found

you may have a different version - not 4.2.1

search \nburn for stdarg.h

eclipse may require forward slashes, I don't know

good hunting

Chris

Re: vsprintf question

Posted: Fri Jun 03, 2011 10:25 am
by zx5000
Getting closer. The inclusion error goes away but I still get compile errors.

Tried pointing to both stdarg.h folders.

C:\nburn\gcc-m68k\m68k-elf\include/stdio.h:251: error: '__gnuc_va_list' has not been declared

Re: vsprintf question

Posted: Fri Jun 03, 2011 10:32 am
by tod
It sounds like you may not know how to add an include directory path in Eclipse for GCC. In a blog entry on getting started with NetBurner I have a screencast that goes through the process at about the 1:45 point. It is showing how to include the sim5270.h file so you'll just need to do what's shown there but navigate to the include directory that has the .h file you are interested in.

There is also a written description of the process (and how to make it so all projects include a particular directory) on the wiki entry on moving to C++.

[EDIT]
I would think the one (and only) directory you want to include for stdarg.h is
c:\nburn\gcc-m68k\lib\gcc\m68k-elf\4.2.1\include\stdarg.h

This assumes the 4.2.1 release of the gnu toolchain.

Re: vsprintf question

Posted: Fri Jun 03, 2011 10:44 am
by zx5000
Here is the screencap from my paths. I did this earlier when I got rid of the inclusion error.