C and C++ don't mix, Something wrong with my header?

Discussion in 'C++' started by ssndk123@gmail.com, Apr 16, 2008.

  1. Guest

    Hi,

    I'm trying to include some C functions from IOPort.h/cpp to my C++
    program.. i placed the IOPort.h into stdafx, but when I try to
    compile i get the errors like: ioport.h(8) : error C2065: 'UINT' :
    undeclared identifier. So, the Visual Studio 2005 compiler doesn't
    know what UNIT is?

    Am I doing something wrong? I attached my code below.

    I'd appreciate any help..

    Thanks,
    Soren

    -------------------------------------------------
    stdafx.h:
    -------------------------------------------------
    #pragma once

    #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP
    or later.
    #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to
    target other versions of Windows.
    #endif

    #include <stdio.h>
    #include <tchar.h>
    #include "IOPort.h"

    -----------------------------------------------
    IOPort.h:
    ------------------------------------------------
    #ifndef IOPORTH
    #define IOPORTH

    #ifdef __cplusplus
    extern "C" {
    #endif

    void outport(UINT portid, UINT value);
    void outportb(UINT portid, BYTE value);
    BYTE inportb(UINT portid);
    UINT inport(UINT portid);
    BOOL StartUpIoPorts(UINT PortToAccess, BOOL bShowMessageBox, HWND
    hParentWnd);

    #ifdef __cplusplus
    }
    #endif

    #endif

    ---------------------------------------------------
    testmain:
    ----------------------------------------------------
    #include "stdafx.h"
    #include <iostream>

    using namespace std;

    int main()
    {
    char i;
    cout << "Hello World!!";
    cin >> i;
    return 0;
    }
     
    , Apr 16, 2008
    #1
    1. Advertising

  2. Noah Roberts Guest

    OT: Re: C and C++ don't mix, Something wrong with my header?

    wrote:
    > Hi,
    >
    > I'm trying to include some C functions from IOPort.h/cpp to my C++
    > program.. i placed the IOPort.h into stdafx, but when I try to
    > compile i get the errors like: ioport.h(8) : error C2065: 'UINT' :
    > undeclared identifier. So, the Visual Studio 2005 compiler doesn't
    > know what UNIT is?


    That's because it's declared in the windows.h header, or one that it
    includes. Pretty sure anyway.

    Make sure ioport.h is included after this. That will fix your immediate
    problem. Then as was said, ask vc specific questions in a vc newsgroup.
     
    Noah Roberts, Apr 16, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jason
    Replies:
    0
    Views:
    807
    jason
    Aug 30, 2006
  2. mlt
    Replies:
    2
    Views:
    852
    Jean-Marc Bourguet
    Jan 31, 2009
  3. Joel Smith
    Replies:
    1
    Views:
    486
    Peter Otten
    Oct 6, 2009
  4. Brian Candler

    Bug? Serial ports and threads don't mix

    Brian Candler, Sep 2, 2004, in forum: Ruby
    Replies:
    0
    Views:
    146
    Brian Candler
    Sep 2, 2004
  5. J Krugman

    use constant and BEGIN don't mix?

    J Krugman, Apr 30, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    99
    Anno Siegel
    May 1, 2004
Loading...

Share This Page