Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

This forum covers PCAN-Linux and Linux development issues concerning our products
Locked
Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Post by Fojtik » Fri 31. Jan 2020, 12:25

I have found a critical issue.

Code: Select all

typedef __signed__ int __s32;
typedef unsigned int __u32;
this __u32 has size 64 bit and not 32 bit.

pcan.h forces:

Code: Select all

#else
#define DWORD  __u32
#define WORD   __u16
#define BYTE   __u8
#endif
DWORD to 64 bit int and it corrupts my code. Is there any way how to get out from this unwanted mess?
Attachments
pcan.h
Standard Peak include header.
(8.84 KiB) Downloaded 317 times
int-ll64.h
Definition of __u32 in Ubuntu.
(801 Bytes) Downloaded 305 times

User avatar
S.Grosjean
Software Development
Software Development
Posts: 357
Joined: Wed 4. Jul 2012, 17:02

Re: Critical defect pcan.h pollutes DWORD on Ubuntu

Post by S.Grosjean » Fri 31. Jan 2020, 12:40

Hi,

Please first give us the error "message" you're just talking about. This would be very helpful to better help you.

Next:

Code: Select all

$ uname -a
Linux linux-dev 5.3.0-19-generic #20-Ubuntu SMP Fri Oct 18 09:04:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
$ cat sizeof.c
#include <stdio.h>

int main(int argc, char *argv[])
{
        printf("sizeof(unsigned char)=%lu\n", sizeof(unsigned char));
        printf("sizeof(unsigned short)=%lu\n", sizeof(unsigned short));
        printf("sizeof(unsigned int)=%lu\n", sizeof(unsigned int));
        printf("sizeof(unsigned long)=%lu\n", sizeof(unsigned long));

        return 0;
}
$ gcc sizeof.c -o sizeof
$ ./sizeof
sizeof(unsigned char)=1
sizeof(unsigned short)=2
sizeof(unsigned int)=4
sizeof(unsigned long)=8
Regards,
— Stéphane

Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Post by Fojtik » Fri 31. Jan 2020, 12:54

The header pcan.c is from 2010.

C standard 2011 define these types:
https://pubs.opengroup.org/onlinepubs/0 ... int.h.html
https://en.cppreference.com/w/cpp/types/integer

Code: Select all

The following types are required:
int8_t
int16_t
int32_t
uint8_t
uint16_t
uint32_t

Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Post by Fojtik » Fri 31. Jan 2020, 13:04

It seems that there is something more weird:

Code: Select all

  printf("__u32 %ld __u16 %ld __u8 %ld\n", sizeof(__u32), sizeof(__u16), sizeof(__u8));

  printf("sizeof(unsigned char)=%lu\n", sizeof(unsigned char));
  printf("sizeof(unsigned short)=%lu\n", sizeof(unsigned short));
  printf("sizeof(unsigned int)=%lu\n", sizeof(unsigned int));
  printf("sizeof(unsigned long)=%lu\n", sizeof(unsigned long));
__u32 8 __u16 2 __u8 1
sizeof(unsigned char)=1
sizeof(unsigned short)=2
sizeof(unsigned int)=4
sizeof(unsigned long)=8

Fojtik
Posts: 30
Joined: Thu 8. Feb 2018, 13:06

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Post by Fojtik » Fri 31. Jan 2020, 13:30

Excuse me, another header collided with DWORD. Now seems everything OK.

Code: Select all

__u32 4 __u16 2 __u8 1
sizeof(unsigned char)=1
sizeof(unsigned short)=2
sizeof(unsigned int)=4
sizeof(unsigned long)=8

This thread could be erased not to confuse others.

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Critical defect pcan.h pollutes DWORD on Ubuntu to 64 bits

Post by PEAK-Support » Fri 31. Jan 2020, 23:11

This is NOT the first time that you post „errors“ and talk about „bug“and „problems“ and at the end you are the problem and you waste our time. See also this post post
Please think before you write and try first to find your own problems before post it here.
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Locked