C function problems during porting from UNIX to Windows 
Author Message
 C function problems during porting from UNIX to Windows

Hi all,
I have a big problem for my short experience!
A software working fine on UNIX environment, when is compiled and run
on Windows environment doesn't work.
I located problem on "close(int fildes)" function (correctly defined
on UNIX).
Above function doesn't work on windows environment returning -1 as
value and 9 as code error (EBADF).
Someone can help me?
Thanks in advance!


Mon, 05 Dec 2005 22:28:39 GMT  
 C function problems during porting from UNIX to Windows

Quote:
>Hi all,
>I have a big problem for my short experience!
>A software working fine on UNIX environment, when is compiled and run
>on Windows environment doesn't work.
>I located problem on "close(int fildes)" function (correctly defined
>on UNIX).

The 'close()' function is not a standard C function. It's definition,
invocation, actions and results are platform and compiler dependant.

Quote:
>Above function doesn't work on windows environment returning -1 as
>value and 9 as code error (EBADF).

Well, my /guess/ is that, under Windows, you aren't permitted to close files
(either all or some) in this manner.

Your best bet is to take this to one of the comp.os.ms-windows newsgroups or a
newsgroup that covers your particular compiler, and see what they have to say.

Lew Pitcher
IT Consultant, Enterprise Technology Solutions
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')



Mon, 05 Dec 2005 22:44:36 GMT  
 C function problems during porting from UNIX to Windows


Quote:
> Hi all,
> I have a big problem for my short experience!
> A software working fine on UNIX environment, when is compiled and run
> on Windows environment doesn't work.
> I located problem on "close(int fildes)" function (correctly defined
> on UNIX).
> Above function doesn't work on windows environment returning -1 as
> value and 9 as code error (EBADF).
> Someone can help me?

It will be easier if you ask us about a standard C function like fclose.
 It is meaningless to assert for standard C that close is "correctly
defined on UNIX."  It has no definition at all for C.

--
Martin Ambuhl
now exiled to
Hurricane Bait, Texas



Mon, 05 Dec 2005 23:25:26 GMT  
 C function problems during porting from UNIX to Windows

Quote:
> I have a big problem for my short experience!
> A software working fine on UNIX environment, when is compiled and run
> on Windows environment doesn't work.
> I located problem on "close(int fildes)" function (correctly defined
> on UNIX).
> Above function doesn't work on windows environment returning -1 as
> value and 9 as code error (EBADF).
> Someone can help me?

Yes: u standard I/O function (those commencing with 'f')
fopen(), fgetc() etc. as declared in <stdio.h>

--

The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-library: http://www.dinkumware.com/htm_cl/index.html
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/



Tue, 06 Dec 2005 00:55:26 GMT  
 C function problems during porting from UNIX to Windows

Quote:
> Yes: u[*] standard I/O function (those commencing with 'f')

[*] se (I meant 'use')

Quote:
> fopen(), fgetc() etc. as declared in <stdio.h>

--

The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
C-library: http://www.dinkumware.com/htm_cl/index.html
FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/


Tue, 06 Dec 2005 01:55:38 GMT  
 C function problems during porting from UNIX to Windows

Quote:
>I have a big problem for my short experience!
>A software working fine on UNIX environment, when is compiled and run
>on Windows environment doesn't work.
>I located problem on "close(int fildes)" function (correctly defined
>on UNIX).
>Above function doesn't work on windows environment returning -1 as
>value and 9 as code error (EBADF).

If the implementation provides the non-standard close(), it should work.
Check that the file descriptor you're passing to close() is correct.
Also check your Windows implementation documentation WRT close(), to be
sure that the Windows version has the UNIX semantics.

Since this is a porting between UNIX and Windows problem, rather than a
standard C problem, I would suggest crossposting to comp.unix.programmer
and comp.os.ms-windows.programmer.win32 if my advice was not enough to
solve the problem.

Dan
--
Dan Pop
DESY Zeuthen, RZ group



Tue, 06 Dec 2005 20:04:07 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. UNIX->MS-WINDOWS Porting Problem

2. Porting C from Windows to UNIX?

3. Porting C ANSI Between Unix and Windows NT

4. Porting Unix to Windows (pthread.h)

5. Information on porting unix-->windows regarding shared memory emulation

6. Issues porting source from Unix to Windows

7. Unix to Windows/ActiveX port

8. Thread safe calls..( porting from unix to windows )

9. Porting Windows 98 apllication to Windows 2000 problem.

10. Porting UNIX to WIN32 - strptime() function

11. port from UNIX to NT problem

12. VC++ 5.0 porting problem (from Unix)

 

 
Powered by phpBB® Forum Software