Sujet : Re: New VSI post on Youtube
De : arne (at) *nospam* vajhoej.dk (Arne Vajhøj)
Groupes : comp.os.vmsDate : 14. Aug 2024, 21:23:47
Autres entêtes
Organisation : SunSITE.dk - Supporting Open source
Message-ID : <66bd1252$0$717$14726298@news.sunsite.dk>
References : 1 2 3 4 5
User-Agent : Mozilla Thunderbird
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
#ifdef __cplusplus
extern "C" {
#endif
struct data
{
long a;
long b;
long c;
long d;
};
#ifdef __cplusplus
}
#endif
$ type long1.cxx
#include "long.h"
extern "C" {
void f(struct data *d);
}
int main()
{
struct data o;
o.a = 1;
o.b = 2;
o.c = 3;
o.d = 4;
f(&o);
return 0;
}
$ type long2.c
#include <stdio.h>
#include "long.h"
void f(struct data *o)
{
printf("%ld %ld %ld %ld\n", o->a, o->b, o->c, o->d);
}
$ cxx/name=upper long1
$ cc long2
$ link/exe=long long1 + long2
$ run long
1 0 2 0
Arne