[Info-vax] New VSI post on Youtube

Arne Vajhøj arne at vajhoej.dk
Thu Sep 5 13:30:56 EDT 2024


On 8/14/2024 4:23 PM, Arne Vajhøj wrote:
> On 8/14/2024 2:33 PM, Arne Vajhøj wrote:
>> And it has different size of long and pointers. Causing problems
>> for two cases:
>> * code that make implicit assumptions that those are 32 bit
>> * mixing C and C++
> 
> And in case someone has not seen it:
> 
> $ type long.h

And the same with pointers:

$ type ptr.h
#ifdef __cplusplus
extern "C" {
#endif

struct data
{
     void* a;
     void* b;
     void* c;
     void* d;
};

#ifdef __cplusplus
}
#endif
$ type ptr1.cxx
#include "ptr.h"

extern "C" {
void f(struct data *d);
}

int main()
{
     struct data o;
     o.a = (void *)1;
     o.b = (void *)2;
     o.c = (void *)3;
     o.d = (void *)4;
     f(&o);
     return 0;
}
$ type ptr2.c
#include <stdio.h>

#include "ptr.h"

void f(struct data *o)
{
     printf("%p %p %p %p\n", o->a, o->b, o->c, o->d);
}
$ cxx/name=upper ptr1
$ cc ptr2
$ link/exe=ptr ptr1 + ptr2
$ run ptr
1 0 2 0
$ cxx/name=upper/pointer=32  ptr1
$ cc ptr2
$ link/exe=ptr ptr1 + ptr2
$ run ptr
1 2 3 4
$ cxx/name=upper ptr1
$ cc/pointer=64 ptr2
$ link/exe=ptr ptr1 + ptr2
$ run ptr
1 2 3 4

Arne




More information about the Info-vax mailing list