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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 wrapper function for printf

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bg-phys Posted - 08/11/2006 : 12:57:03 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
bg-phys Posted - 08/11/2006 : 5:08:15 PM
Good idea. Thanks again.


easwar Posted - 08/11/2006 : 3:37:39 PM
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
bg-phys Posted - 08/11/2006 : 2:25:26 PM
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.


easwar Posted - 08/11/2006 : 1:42:08 PM
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



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000