Pelles C forum

Pelles C => Bug reports => Topic started by: Fuerst on December 12, 2023, 07:05:05 PM

Title: #include <unistd.h> + <process.h> -> not compilable
Post by: Fuerst on December 12, 2023, 07:05:05 PM
Compiling the following C-Code ...
Code: [Select]
#include <unistd.h>
#include <process.h>

int main(void)
{
return 0;
}
... using Pelles-C 12.00.2 fails:
Quote
O:\Sources\Test>pocc -Go test.c
C:\Program Files\PellesC\Include\process.h(99): error #2119: Redeclaration of 'execv', previously declared at C:\Program Files\PellesC\Include\unistd.h(85).
C:\Program Files\PellesC\Include\process.h(100): error #2119: Redeclaration of 'execve', previously declared at C:\Program Files\PellesC\Include\unistd.h(86).
C:\Program Files\PellesC\Include\process.h(101): error #2119: Redeclaration of 'execvp', previously declared at C:\Program Files\PellesC\Include\unistd.h(87).
Title: Re: #include <unistd.h> + <process.h> -> not compilable
Post by: TimoVJL on December 12, 2023, 07:10:28 PM
Those headers are normally not used same time.

https://en.wikipedia.org/wiki/Process.h

Title: Re: #include <unistd.h> + <process.h> -> not compilable
Post by: Vortex on December 12, 2023, 07:15:50 PM
Quote
In the C and C++ programming languages, unistd.h is the name of the header file that provides access to the POSIX operating system API.

https://en.wikipedia.org/wiki/Unistd.h

https://copyprogramming.com/howto/is-there-a-replacement-for-unistd-h-for-windows-visual-c
Title: Re: #include <unistd.h> + <process.h> -> not compilable
Post by: frankie on December 12, 2023, 08:53:50 PM
Bug confirmed.
The 3 functions are declared differently in the two headers:
Code: [Select]
// process.h
extern intptr_t __cdecl execv(const char *, char * const []);
extern intptr_t __cdecl execve(const char *, char * const [], char * const []);
extern intptr_t __cdecl execvp(const char *, char * const []);

Code: [Select]
// unistd.h
extern intptr_t __cdecl execv(const char *, const char * const []);
extern intptr_t __cdecl execve(const char *, const char * const [], const char * const []);
extern intptr_t __cdecl execvp(const char *, const char * const []);
Title: Re: #include <unistd.h> + <process.h> -> not compilable
Post by: TimoVJL on December 13, 2023, 09:57:49 AM
It seems, that headers was mixed together.
From docs:
Code: [Select]
// process.h
extern intptr_t __cdecl execv(const char *, const char * const []);
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/execv-wexecv?view=msvc-170

Code: [Select]
// unistd.h
extern intptr_t __cdecl execv(const char *, char * const []);
https://linux.die.net/man/3/execv
Title: Re: #include <unistd.h> + <process.h> -> not compilable
Post by: frankie on December 13, 2023, 10:23:00 AM
It seems, that headers was mixed together.
From docs:
Code: [Select]
// process.h
extern intptr_t __cdecl execv(const char *, const char * const []);
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/execv-wexecv?view=msvc-170

Code: [Select]
// unistd.h
extern intptr_t __cdecl execv(const char *, char * const []);
https://linux.die.net/man/3/execv
Yes, the problem is that MS is tollerant about those differences, while PellesC is stricly compliant with the standard and signal the error.
Anyway the SDK should be convergent to allow the use of both IMO.