* Re: [9fans] binary sprint format
[not found] <634008374f96d39b2953843bc63d67ff@plan9.bell-labs.com>
@ 2009-08-07 3:47 ` Adriano Verardo
0 siblings, 0 replies; 10+ messages in thread
From: Adriano Verardo @ 2009-08-07 3:47 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
jmk@plan9.bell-labs.com wrote:
> the kernel library include file (../port/lib.h)
> does not have a pragma in it for %b. if this is
> indeed a kernel driver you are writing then you
> should add the pragma in the driver:
>
> #pragma varargck type "b" int
>
> the reason the kernel does not just use <libc.h>
> is to catch the inadvertent use of routines from
> libc.a that just won't work if used in the kernel
> (e.g. functions that do system calls). if %b becomes
> commonly used in the kernel and is safe to use
> (not all format specifiers are safe in the kernel,
> e.g. those for floating point) then it will find
> its way into ../port/lib.h.
>
> --jim
>
>
>
It works perfectly.
Thank you very much, Jim.
adriano
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 8:37 ` Greg Comeau
@ 2009-08-07 12:52 ` erik quanstrom
0 siblings, 0 replies; 10+ messages in thread
From: erik quanstrom @ 2009-08-07 12:52 UTC (permalink / raw)
To: comeau, 9fans
On Fri Aug 7 04:44:37 EDT 2009, comeau@panix.com wrote:
> In article <4A7B6EF7.6090305@tecmav.com>,
> Adriano Verardo <a.verardo@tecmav.com> wrote:
> >I'm trying to convert integers in text binary format by sprint(...,
> >"%b", i),
> >but 8c issue a "format mismatch b INT" warning message.
> >
> >Can anyone kindly explain to me my mistake ?
> >Doesn't "%b" behave like the other integer format specifications ?
>
> Sound like you may want %d, however, not sure what you're trying
> to do, since dunno what you mean by text binary or if you were just
> cutting corners with ... but run "man sprintf" and have a look.
if only the man page had been read and corners had not been cut ...
here's what was missed:
- the message (http://9fans.net/archive/2009/08/191) explaining
the solution which was sent several hrs earlier,
- that he was using sprint, not sprintf from stdio,
- that %b is a legitimate sprint verb.
- erik
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:34 ` erik quanstrom
2009-08-07 1:27 ` Adriano Verardo
@ 2009-08-07 8:37 ` kjs
1 sibling, 0 replies; 10+ messages in thread
From: kjs @ 2009-08-07 8:37 UTC (permalink / raw)
To: 9fans
On Aug 6, 7:31Â pm, a.vera...@tecmav.com (Adriano Verardo) wrote:
> erik quanstrom wrote:
> >>> i believe you need to update your libc.h. Â you need pragmas for
> >>> the "b" format, which were added 2007/0108.
>
> >>> - erik
>
> >> I'm using a distribution downloaded about 2 months ago. The machine has
> >> been installed from scratch.
>
> > perhaps you have not included everything necessary?
>
> > ; cat fmtb.c
> > #include <u.h>
> > #include <libc.h>
>
> > void
> > main(void)
> > {
> > Â Â print("%b\n", 16);
> > Â Â exits("");
> > }
>
> > ; 8c -FVTw fmtb.c && 8l fmtb.8 && 8.out
> > 10000
>
> > - erik
>
> Your example works on my machine too.
>
> What could be the reason why 8c complains about sprint(buf, "%b", 16) in
> a driver whose includes are:
>
> #include "u.h"
> #include "../port/lib.h"
> #include "mem.h"
> #include "dat.h"
> #include "fns.h"
>
> Am I using them in a wrong way ?
>
> adriano
uhm ... libc.h
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:01 Adriano Verardo
2009-08-07 0:08 ` erik quanstrom
@ 2009-08-07 8:37 ` Greg Comeau
2009-08-07 12:52 ` erik quanstrom
1 sibling, 1 reply; 10+ messages in thread
From: Greg Comeau @ 2009-08-07 8:37 UTC (permalink / raw)
To: 9fans
In article <4A7B6EF7.6090305@tecmav.com>,
Adriano Verardo <a.verardo@tecmav.com> wrote:
>I'm trying to convert integers in text binary format by sprint(...,
>"%b", i),
>but 8c issue a "format mismatch b INT" warning message.
>
>Can anyone kindly explain to me my mistake ?
>Doesn't "%b" behave like the other integer format specifications ?
Sound like you may want %d, however, not sure what you're trying
to do, since dunno what you mean by text binary or if you were just
cutting corners with ... but run "man sprintf" and have a look.
--
Greg Comeau / 4.3.10.1 with C++0xisms now in beta!
Comeau C/C++ ONLINE ==> http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
@ 2009-08-07 2:15 Akshat Kumar
0 siblings, 0 replies; 10+ messages in thread
From: Akshat Kumar @ 2009-08-07 2:15 UTC (permalink / raw)
To: 9fans
> #include "u.h"
> #include "../port/lib.h"
> #include "mem.h"
> #include "dat.h"
> #include "fns.h"
Perhaps libc.h?
ak
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:34 ` erik quanstrom
@ 2009-08-07 1:27 ` Adriano Verardo
2009-08-07 8:37 ` kjs
1 sibling, 0 replies; 10+ messages in thread
From: Adriano Verardo @ 2009-08-07 1:27 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
erik quanstrom wrote:
>>> i believe you need to update your libc.h. you need pragmas for
>>> the "b" format, which were added 2007/0108.
>>>
>>> - erik
>>>
>>>
>>>
>>>
>>>
>> I'm using a distribution downloaded about 2 months ago. The machine has
>> been installed from scratch.
>>
>
> perhaps you have not included everything necessary?
>
> ; cat fmtb.c
> #include <u.h>
> #include <libc.h>
>
> void
> main(void)
> {
> print("%b\n", 16);
> exits("");
> }
>
> ; 8c -FVTw fmtb.c && 8l fmtb.8 && 8.out
> 10000
>
> - erik
>
>
Your example works on my machine too.
What could be the reason why 8c complains about sprint(buf, "%b", 16) in
a driver whose includes are:
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
Am I using them in a wrong way ?
adriano
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:30 ` Adriano Verardo
@ 2009-08-07 0:34 ` erik quanstrom
2009-08-07 1:27 ` Adriano Verardo
2009-08-07 8:37 ` kjs
0 siblings, 2 replies; 10+ messages in thread
From: erik quanstrom @ 2009-08-07 0:34 UTC (permalink / raw)
To: 9fans
> > i believe you need to update your libc.h. you need pragmas for
> > the "b" format, which were added 2007/0108.
> >
> > - erik
> >
> >
> >
> >
> I'm using a distribution downloaded about 2 months ago. The machine has
> been installed from scratch.
perhaps you have not included everything necessary?
; cat fmtb.c
#include <u.h>
#include <libc.h>
void
main(void)
{
print("%b\n", 16);
exits("");
}
; 8c -FVTw fmtb.c && 8l fmtb.8 && 8.out
10000
- erik
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:08 ` erik quanstrom
@ 2009-08-07 0:30 ` Adriano Verardo
2009-08-07 0:34 ` erik quanstrom
0 siblings, 1 reply; 10+ messages in thread
From: Adriano Verardo @ 2009-08-07 0:30 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
erik quanstrom wrote:
> On Thu Aug 6 20:03:20 EDT 2009, a.verardo@tecmav.com wrote:
>
>> Hi, all
>>
>> I'm trying to convert integers in text binary format by sprint(...,
>> "%b", i),
>> but 8c issue a "format mismatch b INT" warning message.
>>
>> Can anyone kindly explain to me my mistake ?
>> Doesn't "%b" behave like the other integer format specifications ?
>>
>> Thanks in advance
>>
>
> i believe you need to update your libc.h. you need pragmas for
> the "b" format, which were added 2007/0108.
>
> - erik
>
>
>
>
I'm using a distribution downloaded about 2 months ago. The machine has
been installed from scratch.
adriano
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [9fans] binary sprint format
2009-08-07 0:01 Adriano Verardo
@ 2009-08-07 0:08 ` erik quanstrom
2009-08-07 0:30 ` Adriano Verardo
2009-08-07 8:37 ` Greg Comeau
1 sibling, 1 reply; 10+ messages in thread
From: erik quanstrom @ 2009-08-07 0:08 UTC (permalink / raw)
To: 9fans
On Thu Aug 6 20:03:20 EDT 2009, a.verardo@tecmav.com wrote:
> Hi, all
>
> I'm trying to convert integers in text binary format by sprint(...,
> "%b", i),
> but 8c issue a "format mismatch b INT" warning message.
>
> Can anyone kindly explain to me my mistake ?
> Doesn't "%b" behave like the other integer format specifications ?
>
> Thanks in advance
i believe you need to update your libc.h. you need pragmas for
the "b" format, which were added 2007/0108.
- erik
^ permalink raw reply [flat|nested] 10+ messages in thread
* [9fans] binary sprint format
@ 2009-08-07 0:01 Adriano Verardo
2009-08-07 0:08 ` erik quanstrom
2009-08-07 8:37 ` Greg Comeau
0 siblings, 2 replies; 10+ messages in thread
From: Adriano Verardo @ 2009-08-07 0:01 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Hi, all
I'm trying to convert integers in text binary format by sprint(...,
"%b", i),
but 8c issue a "format mismatch b INT" warning message.
Can anyone kindly explain to me my mistake ?
Doesn't "%b" behave like the other integer format specifications ?
Thanks in advance
adriano
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-08-07 12:52 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <634008374f96d39b2953843bc63d67ff@plan9.bell-labs.com>
2009-08-07 3:47 ` [9fans] binary sprint format Adriano Verardo
2009-08-07 2:15 Akshat Kumar
-- strict thread matches above, loose matches on Subject: below --
2009-08-07 0:01 Adriano Verardo
2009-08-07 0:08 ` erik quanstrom
2009-08-07 0:30 ` Adriano Verardo
2009-08-07 0:34 ` erik quanstrom
2009-08-07 1:27 ` Adriano Verardo
2009-08-07 8:37 ` kjs
2009-08-07 8:37 ` Greg Comeau
2009-08-07 12:52 ` erik quanstrom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).