Preprocessor Statements

General discussion on Package Manager Software.
Post Reply
Author
Message
borris
Posts: 219
Joined: 22 Aug 2011 07:13

Preprocessor Statements

#1 Post by borris » 18 Sep 2012 21:19

I've developed several of my own libraries and love the ability to click a box and have the library functions available everywhere, but that isn't my question.


Are #define statements filtered out or ignored in librarys? Seems like all of my #define statements that I compile into a package don't retain those definitions. Is this correct or am I messing something up?

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Preprocessor Statements

#2 Post by filip » 19 Sep 2012 12:58

Hi,

Please, can you attach here an example of your library so I could understand your question better ?

Regards,
Filip .

borris
Posts: 219
Joined: 22 Aug 2011 07:13

Re: Preprocessor Statements

#3 Post by borris » 25 Sep 2012 22:56

Code: Select all

#ifndef __TFP_PRINTF__
#define __TFP_PRINTF__

#include <stdarg.h>

void init_printf(void* putp,void (*putf) (void*,char));

void tfp_printf(char *fmt, ...);
void tfp_sprintf(char* s,char *fmt, ...);

void tfp_format(void* putp,void (*putf) (void*,char),char *fmt, va_list va);

#define printf tfp_printf 
#define sprintf tfp_sprintf 

#endif
printf define and sprintf define are not recognized when put into a package / library.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Preprocessor Statements

#4 Post by filip » 28 Sep 2012 14:37

Hi,

The scope of #DEFINE is limited to single source file where it is defined, so when you try to use it outside of this source (in your case library) you will get errors.

Regards,
Filip.

borris
Posts: 219
Joined: 22 Aug 2011 07:13

Re: Preprocessor Statements

#5 Post by borris » 02 Oct 2012 00:24

That is what I kind of figured, but I was hoping that the library would be treated like a header file and when included it would act as a #include statement behind the scenes.

I re-compiled the library to rename the functions to what I needed them to be.

Thanks.

Post Reply

Return to “Package Manager General”