All of lore.kernel.org
 help / color / mirror / Atom feed
* C question
@ 2009-10-08  2:12 Rick Brown
  2009-10-08  2:52 ` Manish Katiyar
  2009-10-08  3:02 ` mayur nande
  0 siblings, 2 replies; 16+ messages in thread
From: Rick Brown @ 2009-10-08  2:12 UTC (permalink / raw)
  To: kernelnewbies, linux-newbie

Hello list,

As far as I recall from K&R, isn't pointer arithmetic on a void
pointer banned? And any effort to do that results in an error -
because the compiler won't know by how much size to increment the
pointer for a statement like "ptr++"? But then how about this:

[rick@linux rick]$ cat t.c
#include <stdio.h>
int main()
{
    void *ptr = 0;
    printf("%d \n", ptr+1);
}
[rick@linux rick]$ gcc t.c
[rick@linux rick]$ ./a.out
1
[rick@linux rick]$

It compiles and runs fine ... !

TIA,

Rick

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ


^ permalink raw reply	[flat|nested] 16+ messages in thread
* C Question
@ 2010-05-25 10:08 Randi Botse
  2010-05-25 10:19 ` Xiaotian Feng
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Randi Botse @ 2010-05-25 10:08 UTC (permalink / raw)
  To: linux-c-programming

Hi All,

Im looking at lscpu.c shipped by util-linux-ng-2.17, can you explain
me how the *vir_types[] declared, is this valid C declaration?

/* virtualization types */
enum {
	VIRT_NONE	= 0,
	VIRT_PARA,
	VIRT_FULL
};
const char *virt_types[] = {
	[VIRT_NONE]	= N_("none"),
	[VIRT_PARA]	= N_("para"),
	[VIRT_FULL]	= N_("full")
};

^ permalink raw reply	[flat|nested] 16+ messages in thread
* C++ Question
@ 1999-10-21  1:40 ian reinhart geiser
  0 siblings, 0 replies; 16+ messages in thread
From: ian reinhart geiser @ 1999-10-21  1:40 UTC (permalink / raw)
  To: linuxppc-dev


I have confirmed that this works under 2.95 under RH 6.1
one ix86 so I am thinking this is a LinuxPPC problem.

I am building the gcc cross compiler for th 68HC11 using
the 2.8.1 source code and a patch supplied by my professor.

i get the following error:

gcc -c -DCROSS_COMPILE -DIN_GCC    -g  -DHAVE_CONFIG_H    -I. -I.
-I./config fol
d-const.c
fold-const.c: In function `exact_real_inverse':
fold-const.c:945: parse error before `if'
fold-const.c: At top level:
fold-const.c:945: parse error before `else'
fold-const.c:945: parse error before `.'
fold-const.c:945: parse error before `.'
fold-const.c:945: parse error before `.'
fold-const.c:959: parse error before `('
fold-const.c:960: `y' undeclared here (not in a function)
fold-const.c:960: warning: data definition has no type or storage class
fold-const.c:961: parse error before `return'
make: *** [fold-const.o] Error 1     

When I looked at the code i found the following:

exact_real_inverse (mode, r)
     enum machine_mode mode;
     REAL_VALUE_TYPE *r;
{
  union
    {
      double d;
      unsigned short i[4];
    }x, t, y;     
----SNIP----
and at 945 the following code...
941:  /* Truncate to the required mode and range-check the result.  */
942:  y.d = REAL_VALUE_TRUNCATE (mode, t.d);
943:#ifdef CHECK_FLOAT_VALUE
944:  i = 0;
945:	  if (CHECK_FLOAT_VALUE (mode, y.d, i))
946:    goto fail;
947:#endif 

why did i get an error on y.d on 945 and not 941?

any ideas?

sorry if i am missing info, i have been beating on this
for a week and it is all getting blurry...

-ian reinhart geiser


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

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

end of thread, other threads:[~2010-06-01 13:18 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-08  2:12 C question Rick Brown
2009-10-08  2:52 ` Manish Katiyar
2009-10-08  5:37   ` Kalpesh Rathod
2009-10-08  8:48   ` Michał Nazarewicz
2009-10-08  3:02 ` mayur nande
2009-10-08  5:43   ` sandeep lahane
  -- strict thread matches above, loose matches on Subject: below --
2010-05-25 10:08 C Question Randi Botse
2010-05-25 10:19 ` Xiaotian Feng
     [not found]   ` <AANLkTinTu94E7guvzjySpGjht2Hjw4aop4vRIVpHo9UL@mail.gmail.com>
2010-05-25 10:49     ` Randi Botse
2010-05-25 11:18 ` Uriel Corfa
2010-05-25 11:41 ` Michal Nazarewicz
2010-05-30 10:41   ` Randi Botse
2010-05-30 12:38     ` Michal Nazarewicz
2010-06-01 11:59       ` Randi Botse
2010-06-01 13:18         ` Glynn Clements
1999-10-21  1:40 C++ Question ian reinhart geiser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.