CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: fcntl and vs2008

  1. #1
    Join Date
    May 2008

    fcntl and vs2008

    Currently porting code written with vs6 to vs2008, and running in to problems with fcntl (among others).

    with fcntl.h included I am getting errors such as:

    error C2027: use of undefined type 'main::flock'
    error C2065: 'F_RDLCK' : undeclared identifier

    So I looked at the fcntl.h file and the flock structure is not defined, F_RDLCK isn't either.

    Why is this? Is fcntl outdated and should not be use? What should I use instead? Where can I find a copy of fcntl.h that has what I need?

  2. #2
    Join Date
    Oct 2006

    Re: fcntl and vs2008

    Hm, don't have 2008 but are you sure it fcntl.h that causes this? Try declaring what you need yourself instead and comment the fcntl include (just to get the file to compile).

  3. #3
    Join Date
    May 2008

    Re: fcntl and vs2008

    I've done as you suggested and declared the flock structure myself and have commented out the fcntl include. With this, I no longer get the:

    error C2027: use of undefined type 'main::flock'

    This still leads me to believe that there is something wrong with the copy of fcntl.h i have.

    the fcntl.h file found in C:\Program Files\Microsoft Visual Studio 9.0\VC\include reads as follows:

    *fcntl.h - file control options used by open()
    * Copyright (c) Microsoft Corporation. All rights reserved.
    * This file defines constants for the file control options used
    * by the _open() function.
    * [System V]
    * [Public]

    #if _MSC_VER > 1000
    #pragma once

    #include <crtdefs.h>

    #ifndef _INC_FCNTL
    #define _INC_FCNTL

    #define _O_RDONLY 0x0000 /* open for reading only */
    #define _O_WRONLY 0x0001 /* open for writing only */
    #define _O_RDWR 0x0002 /* open for reading and writing */
    #define _O_APPEND 0x0008 /* writes done at eof */

    #define _O_CREAT 0x0100 /* create and open file */
    #define _O_TRUNC 0x0200 /* open and truncate */
    #define _O_EXCL 0x0400 /* open only if file doesn't already exist */

    /* O_TEXT files have <cr><lf> sequences translated to <lf> on read()'s,
    ** and <lf> sequences translated to <cr><lf> on write()'s

    #define _O_TEXT 0x4000 /* file mode is text (translated) */
    #define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
    #define _O_WTEXT 0x10000 /* file mode is UTF16 (translated) */
    #define _O_U16TEXT 0x20000 /* file mode is UTF16 no BOM (translated) */
    #define _O_U8TEXT 0x40000 /* file mode is UTF8 no BOM (translated) */

    /* macro to translate the C 2.0 name used to force binary mode for files */

    #define _O_RAW _O_BINARY

    /* Open handle inherit bit */

    #define _O_NOINHERIT 0x0080 /* child process doesn't inherit file */

    /* Temporary file bit - file is deleted when last handle is closed */

    #define _O_TEMPORARY 0x0040 /* temporary file bit */

    /* temporary access hint */

    #define _O_SHORT_LIVED 0x1000 /* temporary storage file, try not to flush */

    /* sequential/random access hints */

    #define _O_SEQUENTIAL 0x0020 /* file access is primarily sequential */
    #define _O_RANDOM 0x0010 /* file access is primarily random */

    #if !__STDC__ || defined(_POSIX_)
    /* Non-ANSI names for compatibility */
    #define O_RDONLY _O_RDONLY
    #define O_WRONLY _O_WRONLY
    #define O_RDWR _O_RDWR
    #define O_APPEND _O_APPEND
    #define O_CREAT _O_CREAT
    #define O_TRUNC _O_TRUNC
    #define O_EXCL _O_EXCL
    #define O_TEXT _O_TEXT
    #define O_BINARY _O_BINARY
    #define O_RAW _O_BINARY
    #define O_RANDOM _O_RANDOM
    #endif /* __STDC__ */

    #endif /* _INC_FCNTL */

    Clearly there is a lot missing in this file.

    Is fcntl not part of c++ standard and thus only a reduced version is used with vs2008?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)