Re: [naviserver-devel] NS_GNUC_NONNULL on Windows?

2005-07-03 Thread Stephen Deasey
On 6/30/05, Ibrahim Tannir <[EMAIL PROTECTED]> wrote:
> Zoran Vasiljevic wrote:
> >
> > Am 30.06.2005 um 00:47 schrieb Stephen Deasey:
> >
> >> NS_GNUC_NONNULL is only used in the nscheck.h header because I haven't
> >> had time to sprinkle it anywhere else  :-)   I think it's a pretty
> >> useful feature, so I'd like to keep it.
> >>
> >> Macro varargs are not supported by any Microsoft compiler?
> >>
> >
> > No.
> 
> I checked again. No. Neiter does the manual mention it nor does
> the latest compiler accept it.
> 
> >> If you really can't find another solution, then redefining
> >> NS_GNUC_NONNULL to take a single arg should work.  It can be called
> >> multiple times, one for each non-null function argument.  But this is
> >> ugly, so prefer to keep the varargs if you can.
> >
> >
> > Ugly or not, this is what we have and must stick to it.
> > But, this would mean if you start to utilize the macro
> > in generic code, you'd have to use it with only one arg, right?
> 
> There is this old trick - using double parenthesis - to cope with
> this problem in the code, e.g.
> 
> #define MYPRINTF(x) printf x
> 
> MYPRINTF((stderr, "%s\n", "abc"));


I can can live with that.



Re: [naviserver-devel] NS_GNUC_NONNULL on Windows?

2005-06-30 Thread Ibrahim Tannir

Zoran Vasiljevic wrote:


Am 30.06.2005 um 00:47 schrieb Stephen Deasey:


NS_GNUC_NONNULL is only used in the nscheck.h header because I haven't
had time to sprinkle it anywhere else  :-)   I think it's a pretty
useful feature, so I'd like to keep it.

Macro varargs are not supported by any Microsoft compiler?



No.


I checked again. No. Neiter does the manual mention it nor does 
the latest compiler accept it.



If you really can't find another solution, then redefining
NS_GNUC_NONNULL to take a single arg should work.  It can be called
multiple times, one for each non-null function argument.  But this is
ugly, so prefer to keep the varargs if you can.



Ugly or not, this is what we have and must stick to it.
But, this would mean if you start to utilize the macro
in generic code, you'd have to use it with only one arg, right?


There is this old trick - using double parenthesis - to cope with 
this problem in the code, e.g.


#define MYPRINTF(x) printf x

MYPRINTF((stderr, "%s\n", "abc"));



Zoran


Ibrahim



Re: [naviserver-devel] NS_GNUC_NONNULL on Windows?

2005-06-30 Thread Zoran Vasiljevic

Am 30.06.2005 um 00:47 schrieb Stephen Deasey:


NS_GNUC_NONNULL is only used in the nscheck.h header because I haven't
had time to sprinkle it anywhere else  :-)   I think it's a pretty
useful feature, so I'd like to keep it.

Macro varargs are not supported by any Microsoft compiler?



No.


If you really can't find another solution, then redefining
NS_GNUC_NONNULL to take a single arg should work.  It can be called
multiple times, one for each non-null function argument.  But this is
ugly, so prefer to keep the varargs if you can.


Ugly or not, this is what we have and must stick to it.
But, this would mean if you start to utilize the macro
in generic code, you'd have to use it with only one arg, right?

Zoran





Re: [naviserver-devel] NS_GNUC_NONNULL on Windows?

2005-06-29 Thread Stephen Deasey
NS_GNUC_NONNULL is only used in the nscheck.h header because I haven't
had time to sprinkle it anywhere else  :-)   I think it's a pretty
useful feature, so I'd like to keep it.

Macro varargs are not supported by any Microsoft compiler?

If you really can't find another solution, then redefining
NS_GNUC_NONNULL to take a single arg should work.  It can be called
multiple times, one for each non-null function argument.  But this is
ugly, so prefer to keep the varargs if you can.



On 6/29/05, Ibrahim Tannir <[EMAIL PROTECTED]> wrote:
> Hello everybody,
> 
> Please excuse my ignorance in the netickette and use of SF and
> the naviserver project - and please bear with me - I'm still
> learning.
> 
> To Zoran's request (motivated by myself):
> Since NS_GNUC_NONNULL is not used anywhere else but in nscheck.h
> itself and only with GNUC, it suffices to remove it from the
> non-GNUC part to make it compilable for Windows.
> 
> Is it OK with you if I do so?
> 
> Greetings,
> Ibrahim
> 
> 
> 
> Zoran Vasiljevic wrote:
> > Hi frieds,
> >
> > There seems to be a problem with NS_GNUC_NONNULL macro definition
> > when compiling the code on Windows. This is how/where this beast
> > is defined:
> >
> > #if __GNUC_PREREQ(3,3)
> > # define NS_GNUC_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
> > # define NS_GNUC_WARN_UNUSED_RESULT __attribute__
> > ((__warn_unused_result__))
> > # define NS_GNUC_MAYALIAS __attribute__((__may_alias__))
> > #else
> > # define NS_GNUC_NONNULL(...)
> > # define NS_GNUC_WARN_UNUSED_RESULT
> > # define NS_GNUC_MAYALIAS
> > #endif
> >
> > Unfortunately, the
> >
> ># define NS_GNUC_NONNULL(...)
> >
> > will not be accepted by the Microsoft compilers since it is
> > a varargs macro. They do not support varargs macros. Well.
> >
> > Now, idea is to just scrap the NS_GNUC_NONNULL entirely
> > when compiling with non-gcc compilers. Why? Because this
> > macro is really only used IF gcc, and, as far as I can
> > see it is used only here:
> >
> > #if __GNUC_PREREQ(2,7)
> > # define NS_GNUC_UNUSED __attribute__((__unused__))
> > # define NS_GNUC_NORETURN __attribute__((__noreturn__))
> > # define NS_GNUC_PRINTF(m, n) __attribute__((__format__ (__printf__,  m,
> > n))) NS_GNUC_NONNULL(m)
> > # define NS_GNUC_SCANF(m, n) __attribute__((__format__ (__scanf__, m,
> > n))) NS_GNUC_NONNULL(m)
> > #else
> > # define NS_GNUC_UNUSED
> > # define NS_GNUC_NORETURN
> > # define NS_GNUC_PRINTF(fmtarg, firstvararg)
> > # define NS_GNUC_SCANF(fmtarg, firstvararg)
> > #endif
> >
> > Are there any objections to remove the NS_GNUC_NONNULL?
> > Are there any better ideas?
> >
> > Cheers
> > Zoran
> 
> 
> ---
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> ___
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>



Re: [naviserver-devel] NS_GNUC_NONNULL on Windows?

2005-06-29 Thread Ibrahim Tannir

Hello everybody,

Please excuse my ignorance in the netickette and use of SF and 
the naviserver project - and please bear with me - I'm still 
learning.


To Zoran's request (motivated by myself):
Since NS_GNUC_NONNULL is not used anywhere else but in nscheck.h 
itself and only with GNUC, it suffices to remove it from the 
non-GNUC part to make it compilable for Windows.


Is it OK with you if I do so?

Greetings,
Ibrahim



Zoran Vasiljevic wrote:

Hi frieds,

There seems to be a problem with NS_GNUC_NONNULL macro definition
when compiling the code on Windows. This is how/where this beast
is defined:

#if __GNUC_PREREQ(3,3)
# define NS_GNUC_NONNULL(...) __attribute__((__nonnull__(__VA_ARGS__)))
# define NS_GNUC_WARN_UNUSED_RESULT __attribute__ 
((__warn_unused_result__))

# define NS_GNUC_MAYALIAS __attribute__((__may_alias__))
#else
# define NS_GNUC_NONNULL(...)
# define NS_GNUC_WARN_UNUSED_RESULT
# define NS_GNUC_MAYALIAS
#endif

Unfortunately, the

   # define NS_GNUC_NONNULL(...)

will not be accepted by the Microsoft compilers since it is
a varargs macro. They do not support varargs macros. Well.

Now, idea is to just scrap the NS_GNUC_NONNULL entirely
when compiling with non-gcc compilers. Why? Because this
macro is really only used IF gcc, and, as far as I can
see it is used only here:

#if __GNUC_PREREQ(2,7)
# define NS_GNUC_UNUSED __attribute__((__unused__))
# define NS_GNUC_NORETURN __attribute__((__noreturn__))
# define NS_GNUC_PRINTF(m, n) __attribute__((__format__ (__printf__,  m, 
n))) NS_GNUC_NONNULL(m)
# define NS_GNUC_SCANF(m, n) __attribute__((__format__ (__scanf__, m,  
n))) NS_GNUC_NONNULL(m)

#else
# define NS_GNUC_UNUSED
# define NS_GNUC_NORETURN
# define NS_GNUC_PRINTF(fmtarg, firstvararg)
# define NS_GNUC_SCANF(fmtarg, firstvararg)
#endif

Are there any objections to remove the NS_GNUC_NONNULL?
Are there any better ideas?

Cheers
Zoran