9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] porting linux program for beginners
@ 2006-03-14 16:04 Fernan Bolando
  2006-03-14 16:08 ` andrey mirtchovski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Fernan Bolando @ 2006-03-14 16:04 UTC (permalink / raw)
  To: 9fans Mailing list

Hi

I got the following errors when trying out ape on my old programs.
can anybody clarify it's meaning? Are there additional pointers when
porting programs to p9?

what is IND UCHAR and IND CONST CHAR?

dumb_input.c:249[stdin:1718] argument prototype mismatch "IND UCHAR"
for "IND CONST CHAR": strlen

,Fernan

--
Public PGP/GnuPG key (http://www.fernski.com)
pub 1024D/3576CA71 2006-02-02 Fernan Bolando
Key fingerprint = FDFE C9A8 FFED C1A5 2F5C EFEB D595 AF1C 3576 CA71


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] porting linux program for beginners
  2006-03-14 16:04 [9fans] porting linux program for beginners Fernan Bolando
@ 2006-03-14 16:08 ` andrey mirtchovski
  2006-03-14 16:27 ` C H Forsyth
       [not found] ` <4801e8bace9bf2d0ff5a01dd57bf1a79@vitanuova.com>
  2 siblings, 0 replies; 5+ messages in thread
From: andrey mirtchovski @ 2006-03-14 16:08 UTC (permalink / raw)
  To: fernanbolando, Fans of the OS Plan 9 from Bell Labs

for a brief introduction to porting unix code to plan9 i suggest you
check out the config.h file for the links browser (available in
/contrib/andrey on sources). it handles many of the gotchas that
you're bound to encounter.

On 3/14/06, Fernan Bolando <fernanbolando@mailc.net> wrote:
> Hi
>
> I got the following errors when trying out ape on my old programs.
> can anybody clarify it's meaning? Are there additional pointers when
> porting programs to p9?
>
> what is IND UCHAR and IND CONST CHAR?
>
> dumb_input.c:249[stdin:1718] argument prototype mismatch "IND UCHAR"
> for "IND CONST CHAR": strlen
>
> ,Fernan
>
> --
> Public PGP/GnuPG key (http://www.fernski.com)
> pub 1024D/3576CA71 2006-02-02 Fernan Bolando
> Key fingerprint = FDFE C9A8 FFED C1A5 2F5C EFEB D595 AF1C 3576 CA71
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] porting linux program for beginners
  2006-03-14 16:04 [9fans] porting linux program for beginners Fernan Bolando
  2006-03-14 16:08 ` andrey mirtchovski
@ 2006-03-14 16:27 ` C H Forsyth
  2006-03-14 16:47   ` David Leimbach
       [not found] ` <4801e8bace9bf2d0ff5a01dd57bf1a79@vitanuova.com>
  2 siblings, 1 reply; 5+ messages in thread
From: C H Forsyth @ 2006-03-14 16:27 UTC (permalink / raw)
  To: fernanbolando, 9fans

the compiler shows the linear type representation it uses internally.
IND is `indirect', a pointer, or *
UCHAR is `unsigned char'
CONST is obviously `const'
so in

dumb_input.c:249[stdin:1718] argument prototype mismatch "IND UCHAR" for "IND CONST CHAR": strlen

	you're passing an unsigned char* to strlen, which expects const char* (or char*)

the compiler could possibly translate them back to normal C declarator form
from the internal one, but on the other hand, in more subtle cases,
seeing them written in linear form can be helpful if you've got
a * or () in the wrong place.

newer versions of gcc will object too,
so you might as well get the types right now.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] porting linux program for beginners
  2006-03-14 16:27 ` C H Forsyth
@ 2006-03-14 16:47   ` David Leimbach
  0 siblings, 0 replies; 5+ messages in thread
From: David Leimbach @ 2006-03-14 16:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1515 bytes --]

On 3/14/06, C H Forsyth <forsyth@vitanuova.com> wrote:
>
> the compiler shows the linear type representation it uses internally.
> IND is `indirect', a pointer, or *
> UCHAR is `unsigned char'
> CONST is obviously `const'
> so in
>
> dumb_input.c:249[stdin:1718] argument prototype mismatch "IND UCHAR" for
> "IND CONST CHAR": strlen
>
>         you're passing an unsigned char* to strlen, which expects const
> char* (or char*)
>
> the compiler could possibly translate them back to normal C declarator
> form
> from the internal one, but on the other hand, in more subtle cases,
> seeing them written in linear form can be helpful if you've got
> a * or () in the wrong place.



The output is backwards from what I'd expect about the types though.

In C and C++ const always refers to the item on the left of the const,
unless thre isn't one, then you go to the right.

const int
and
int const

are identical

int const *

and

int * const

are not the same :)

So when I read:
"IND CONST CHAR"

my brain is already "wired up" to think of that as

char * const

not

char const *

or equivalently

const char *

Anyone else have this problem?  If it's just me I'll shut up and learn to
cope.

Dave


newer versions of gcc will object too,
> so you might as well get the types right now.



gcc 4.0 is a particularly painful experience when compiling open sourced
codes I've seen that didn't pay attention to pointer target signedness.

Dave

[-- Attachment #2: Type: text/html, Size: 2149 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] porting linux program for beginners
       [not found] ` <4801e8bace9bf2d0ff5a01dd57bf1a79@vitanuova.com>
@ 2006-03-14 18:17   ` Fernan Bolando
  0 siblings, 0 replies; 5+ messages in thread
From: Fernan Bolando @ 2006-03-14 18:17 UTC (permalink / raw)
  To: 9fans

On 3/15/06, C H Forsyth <forsyth@vitanuova.com> wrote:
> the compiler shows the linear type representation it uses internally.
> IND is `indirect', a pointer, or *
> UCHAR is `unsigned char'
> CONST is obviously `const'
> so in
>
> dumb_input.c:249[stdin:1718] argument prototype mismatch "IND UCHAR" for "IND CONST CHAR": strlen
>
>         you're passing an unsigned char* to strlen, which expects const char* (or char*)
>
> the compiler could possibly translate them back to normal C declarator form
> from the internal one, but on the other hand, in more subtle cases,
> seeing them written in linear form can be helpful if you've got
> a * or () in the wrong place.
>
> newer versions of gcc will object too,
> so you might as well get the types right now.

thanks. it is ok now.
I will see if I can get some of my codes posted on my webpage this weekend
It will is mostly some simple ape ports and I am not sure if there is
any real advantage
to port it as a native plan9 program.

--
Public PGP/GnuPG key (http://www.fernski.com)
pub 1024D/3576CA71 2006-02-02 Fernan Bolando
Key fingerprint = FDFE C9A8 FFED C1A5 2F5C EFEB D595 AF1C 3576 CA71


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-03-14 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-14 16:04 [9fans] porting linux program for beginners Fernan Bolando
2006-03-14 16:08 ` andrey mirtchovski
2006-03-14 16:27 ` C H Forsyth
2006-03-14 16:47   ` David Leimbach
     [not found] ` <4801e8bace9bf2d0ff5a01dd57bf1a79@vitanuova.com>
2006-03-14 18:17   ` Fernan Bolando

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).