NO

Author Topic: #include <unistd.h> + <process.h> -> not compilable  (Read 5235 times)

Offline Fuerst

  • Member
  • *
  • Posts: 2
#include <unistd.h> + <process.h> -> not compilable
« 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).

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: #include <unistd.h> + <process.h> -> not compilable
« Reply #1 on: December 12, 2023, 07:10:28 PM »
Those headers are normally not used same time.

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

« Last Edit: December 12, 2023, 07:17:56 PM by TimoVJL »
May the source be with you

Offline Vortex

  • Member
  • *
  • Posts: 865
    • http://www.vortex.masmcode.com
Re: #include <unistd.h> + <process.h> -> not compilable
« Reply #2 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
Code it... That's all...

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: #include <unistd.h> + <process.h> -> not compilable
« Reply #3 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 []);
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: #include <unistd.h> + <process.h> -> not compilable
« Reply #4 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
May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: #include <unistd.h> + <process.h> -> not compilable
« Reply #5 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.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide