vsprintf question

Discussion to talk about software related topics only.
Post Reply
zx5000
Posts: 9
Joined: Sat May 28, 2011 5:50 am

vsprintf question

Post 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
greengene
Posts: 164
Joined: Wed May 14, 2008 11:20 am
Location: Lakeside, CA

Re: vsprintf question

Post 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.
zx5000
Posts: 9
Joined: Sat May 28, 2011 5:50 am

Re: vsprintf question

Post 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
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: vsprintf question

Post 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
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
zx5000
Posts: 9
Joined: Sat May 28, 2011 5:50 am

Re: vsprintf question

Post by zx5000 »

How do you get around the "Unresolved inclusion" error in the nbeclipse?
Attachments
Error on screen.
Error on screen.
netburner.jpeg (174.41 KiB) Viewed 7843 times
User avatar
Chris Ruff
Posts: 222
Joined: Thu Apr 24, 2008 4:09 pm
Location: topsail island, nc
Contact:

Re: vsprintf question

Post 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
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand
zx5000
Posts: 9
Joined: Sat May 28, 2011 5:50 am

Re: vsprintf question

Post 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
User avatar
tod
Posts: 587
Joined: Sat Apr 26, 2008 8:27 am
Location: Southern California
Contact:

Re: vsprintf question

Post 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.
zx5000
Posts: 9
Joined: Sat May 28, 2011 5:50 am

Re: vsprintf question

Post by zx5000 »

Here is the screencap from my paths. I did this earlier when I got rid of the inclusion error.
Attachments
The paths pointing to the stdarg.h
The paths pointing to the stdarg.h
netburner1.jpeg (76.71 KiB) Viewed 7822 times
Post Reply