🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10330

Re: TVINSERTSTRUCT Undefined symbol 'item'

#10330
From: Michael
Date: Thu, 15 Apr 2004 09:06
95 lines
3848 bytes
"Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> wrote:
>
>"Michael" <mloz@mail.com> wrote in message
>news:407e3878$1@newsgroups.borland.com...
>
>> The compiler gives this error:
>> Error E2451 tvtest.c 37: Undefined symbol 'item' in function WinMain
>
>Please show a more complete code snippet, and please quote the EXACT error
>message word-for-word.
>
>
>Gambit
>
>
The complete code to reproduce the error is:
<CODE>
#include <windows.h>
/* #define NONAMELESSUNION <-- HAD NO EFFECT */
#include <commctrl.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {

   TVITEM newTreeItem;
   TVINSERTSTRUCT newTreeItemStruct;

   INITCOMMONCONTROLSEX commonControls = {
      sizeof (INITCOMMONCONTROLSEX),
      ICC_BAR_CLASSES | ICC_TREEVIEW_CLASSES | ICC_LISTVIEW_CLASSES};

   /* Initilize Common Controls (for status bar etc) */
   InitCommonControlsEx(&commonControls);

   newTreeItem.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;

   /* Set the text of the item. */
   newTreeItem.pszText = "Item Name";
   newTreeItem.cchTextMax = sizeof(newTreeItem.pszText)/sizeof(newTreeItem.pszText[0]);

   /* Save the heading level in the item's application-defined data area. */
   newTreeItem.lParam = (LPARAM) 0;

   /* Fill out structure info */
   newTreeItemStruct.hInsertAfter = TVI_LAST;
   newTreeItemStruct.hParent = TVI_ROOT;
   newTreeItemStruct.item = newTreeItem;

   return TRUE;
}
</CODE>

The compiler output is:
bcc32 -tW tvtest.c
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
tvtest.c:
Error E2451 tvtest.c 37: Undefined symbol 'item' in function WinMain
Warning W8057 tvtest.c 43: Parameter 'hInstance' is never used in function WinMain
Warning W8057 tvtest.c 43: Parameter 'hPrevInstance' is never used in function WinMain
Warning W8057 tvtest.c 43: Parameter 'lpCmdLine' is never used in function WinMain
Warning W8057 tvtest.c 43: Parameter 'nCmdShow' is never used in function WinMain
*** 1 errors in Compile ***

Note: Line 37 is this line newTreeItemStruct.item = newTreeItem;

The fix, as I just posted before seeing this message was to add the following #define's before the includes
#define _WIN32_WINNT 0x0300
#define _WIN32_IE 0x0300
or any _WIN32_IE value below 0x0400

Looking at the commctrl.h file, it appears the compiler does not like the
union definition that is in the structure:
<snip from commctrl.h>
typedef struct tagTVINSERTSTRUCTA {
    HTREEITEM hParent;
    HTREEITEM hInsertAfter;
#if (_WIN32_IE >= 0x0400)
    union
    {
        TVITEMEXA itemex;
        TV_ITEMA  item;
    } DUMMYUNIONNAME;
#else
    TV_ITEMA item;
#endif
} TVINSERTSTRUCTA, FAR *LPTVINSERTSTRUCTA;
</snip>

I hope this is enough information, it does seem unusual for a compiler
to come with header files that it cannot work with

Thanx for the reply

Cheers
-- Michael
Technical Details
Message-ID: <407e5090@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <407e3878$1@newsgroups.borland.com> <407e4948$3@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,4dc96a77ba775a75
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-15 02:09:38 PST
From: "Michael" <mloz@mail.com>
Sender: "Michael" <mloz@mail.com>
Reply-To: "Michael" <mloz@mail.com>
Subject: Re: TVINSERTSTRUCT Undefined symbol 'item'
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 210.49.176.217     
References: <407e3878$1@newsgroups.borland.com> <407e4948$3@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <407e5090@newsgroups.borland.com>
Date: 15 Apr 2004 02:06:24 -0700
X-Trace: newsgroups.borland.com 1082019984 207.105.83.66 (15 Apr 2004 02:06:24 -0700)
Lines: 95
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail