The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 wrapper function for printf
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bg-phys

USA
Posts

Posted - 08/11/2006 :  12:57:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version: 7.5 SR5
Operating System: Win XP SP2

I want to write a wrapper function for printf. I found a tutorial on how to do so here.
http://www.thescripts.com/forum/thread212702.html

But it requires including stdarg.h and I get a compilation error when I try to include it.
#include <stdarg.h>

The error is "Error, include file not found"
I get the same error with
#include <stdlib.h> 



I can successfully include the following:

#include <stdio.h> //probably included in Origin.h
#include <Origin.h>
#include "myfile.h"


So it seems to me that stdarg.h is not supported in Origin C. Is this the case?


Edited by - bg-phys on 08/11/2006 1:01:26 PM

easwar

USA
1965 Posts

Posted - 08/11/2006 :  1:42:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi bg-phys,

If you are looking to write the same wrapper function as outlined in the web page you pointed to, you do not need any include file other than Origin.h and you can write code such as:


void test()
{
my_printf("blah blah");
}

int my_printf(string my_string)
{
printf("This is My Header::");
printf("%s\n", my_string);
return 0;
}



You could then put the my_printf() function in a separate C file, make that part of your System branch of Code Builder, and then include a header file in each of your new OC files that has the prototype for that function..

What wrapper function do you exactly want to write? If the above is not exactly what you want and it is something else and just including Origin.h does not work, please post details of your wrapper function.

Easwar
OriginLab


Go to Top of Page

bg-phys

USA
Posts

Posted - 08/11/2006 :  2:25:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I wanted to write:


#include <Origin.h>
#include <stdarg.h>

void test()
{
int value = -1;
debug("Value = %i",value);
}

void debug(char *fmt, ...)
{
#ifdef DEBUG
va_list argp;
fprintf(stderr, "Debug: ");
va_start(argp, fmt);
vfprintf(stderr, fmt, argp);
va_end(argp);
fprintf(stderr, "\n");
#endif // #ifdef DEBUG
}


I'd certainly be willing to settle for using printf and vprintf instead of fprintf and vfprintf.

It seems that a workaround would be to find the source for stdarg.h and all the header files it depends on and copy/save those files to my development directory manually. Hopefully that's not necessary.


Go to Top of Page

easwar

USA
1965 Posts

Posted - 08/11/2006 :  3:37:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi bg-phys,

Maybe something like this, which would need only origin.h include?


#define DEBUG

void test()
{
int value = -1;
debug(value);
}


void debug(int nVal)
{
#ifdef DEBUG
out_int("Debug: Value = ", nVal);
#endif // #ifdef DEBUG
}



Easwar
OriginLab


Edited by - easwar on 08/11/2006 3:40:57 PM
Go to Top of Page

bg-phys

USA
Posts

Posted - 08/11/2006 :  5:08:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Good idea. Thanks again.


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000