9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "David Leimbach" <leimy2k@gmail.com>
To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu>
Subject: Re: [9fans] porting linux program for beginners
Date: Tue, 14 Mar 2006 08:47:39 -0800	[thread overview]
Message-ID: <3e1162e60603140847v3b5b4ad2x8775f0e3348614cb@mail.gmail.com> (raw)
In-Reply-To: <e90f16bde7c247ec408f47e1e48dc7c2@vitanuova.com>

[-- 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 --]

  reply	other threads:[~2006-03-14 16:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-14 16:04 Fernan Bolando
2006-03-14 16:08 ` andrey mirtchovski
2006-03-14 16:27 ` C H Forsyth
2006-03-14 16:47   ` David Leimbach [this message]
     [not found] ` <4801e8bace9bf2d0ff5a01dd57bf1a79@vitanuova.com>
2006-03-14 18:17   ` Fernan Bolando

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e1162e60603140847v3b5b4ad2x8775f0e3348614cb@mail.gmail.com \
    --to=leimy2k@gmail.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).