resolving types

C

cs1975

hi all,

I was trying to compile a test.c using Microsoft CL compiler with
command line , I end up in errors in resolving standard types

unsigned char
char
int

I searched documentation, I did not able to figure out which is
"Header file", which I need to include to resolve these types.

regards,
chandra-
 
M

Mark Bluemel

hi all,

I was trying to compile a test.c using Microsoft CL compiler with
command line , I end up in errors in resolving standard types

unsigned char
char
int

I searched documentation, I did not able to figure out which is
"Header file", which I need to include to resolve these types.

These types are part of the _language_ so require no headers. Your
problem is not related to headers.

It would probably be worth you showing us your code, ideally cut down to
the smallest program which demonstrates your problem.

You should also show us the error messages from your compiler.

For both code and error messages, use "cut and paste" to show us the
real things, rather than transcribing by hand or telling us
approximately what they look like.
 
C

Chris Dollin

I was trying to compile a test.c using Microsoft CL compiler with
command line , I end up in errors in resolving standard types

unsigned char
char
int

I think that's /very/ unlikely. If your compiler is a C compiler,
then it doesn't need to do anything to "resolve" standard types
(and "resolve" isn't the term I'd expect a C compiler to use);
they're hard-wired in to the syntax.

Exactly what did you write and exactly what were the messages?
I searched documentation, I did not able to figure out which is
"Header file", which I need to include to resolve these types.

You don't.
 
S

santosh

hi all,

I was trying to compile a test.c using Microsoft CL compiler with
command line , I end up in errors in resolving standard types

unsigned char
char
int

I searched documentation, I did not able to figure out which is
"Header file", which I need to include to resolve these types.

Show us the code that failed to compile. Cut and paste, don't retype. Either
you're not understanding your problem, or your compiler is seriously
broken.
 
A

Army1987

hi all,

I was trying to compile a test.c using Microsoft CL compiler with
command line , I end up in errors in resolving standard types

unsigned char
char
int

I searched documentation, I did not able to figure out which is
"Header file", which I need to include to resolve these types.

Either you're misunderstanding something, or the compiler is
*seriously* broken.
As others have said, copy and paste the code post it here.
 
C

cs1975

Show us the code that failed to compile. Cut and paste, don't retype. Either
you're not understanding your problem, or your compiler is seriously
broken.

I have gone through MS documentation, did not understood,
please note that W4 warning level is used.


d:/devstudio_6.0/vc98/bin/cl.exe -DMFCDebug -D_DEBUG -DDEBUG -DRWDEBUG
-DWIN32 -D_MBCS -D_AFXDLL -D_WINDOWS -DWinNT400 -DMSVC60 -
DAFX_NOVTABLE= -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 -D_RWTOOLSDLL -
D_
UNICODE -DUNICODE -DO_DLL_PCLASS_ONLY -DBUILD_OcsLog -D_WINDLL -
DCSA_HAS_DLL=1 -DACE_HAS_DLL=1 -ID:\Syngo\include\STLPort -Iw:
\WorkSpaces\DO\include -Iw:\WorkSpaces\src\include -ID:\Syngo\include -
I
D:\include -ID:\syngo\versant\vds605\h -ID:\SDK\include -Id:/
devstudio_6.0/vc98/include -Id:/devstudio_6.0/vc98/atl/include -Id:/
devstudio_6.0/vc98/MFC/include -Iw:\WorkSpaces\src\VT\Components\Log
\sr
c -nologo -MDd -Od -Z7 -GR -GX -G5 -X -GF -EHa -FoOcsLog.obj -
c -W4 w:\WorkSpaces\src\VT\Components\Log\src/OcsLog.c
OcsLog.c
w:\WorkSpaces\src\include\VT/Components/Log/OcsLog.h(21) : error
C2061: syntax error : identifier 'WriteLog'
w:\WorkSpaces\src\include\VT/Components/Log/OcsLog.h(21) : error
C2059: syntax error : ';'
w:\WorkSpaces\src\include\VT/Components/Log/OcsLog.h(21) : error
C2059: syntax error : 'type'
w:\WorkSpaces\src\VT\Components\Log\src/OcsLog.c(5) : error C2061:
syntax error : identifier 'WriteLog'
w:\WorkSpaces\src\VT\Components\Log\src/OcsLog.c(5) : error C2059:
syntax error : ';'
w:\WorkSpaces\src\VT\Components\Log\src/OcsLog.c(5) : error C2059:
syntax error : 'type'

omake: Shell line exit status 2. Stop.

// the header file

#ifndef _OcsLog_h
#define _OcsLog_h 1


bool WriteLog(const char* lpszApp, unsigned short wType, const char*
lpszMessage);



#endif

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
the implementation file
bool WriteLog(const char* lpszApp, unsigned short wType, const char*
lpszMessage)
{
/* I have commented the code */
return true;
}
 
K

Keith Thompson

You see, this is why we ask people to post their exact code and error
messages. The error message you posted later do not refer to unsigned
char, char, or int.

[numerous syntax error messages deleted]
// the header file

#ifndef _OcsLog_h
#define _OcsLog_h 1


bool WriteLog(const char* lpszApp, unsigned short wType, const char*
lpszMessage);



#endif

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
the implementation file
bool WriteLog(const char* lpszApp, unsigned short wType, const char*
lpszMessage)
{
/* I have commented the code */
return true;
}

The problem is 'bool' (and 'true').

Unlike 'int' and 'char', 'bool' is not a predefined type in C (and
'true' is not a predefined identifier). The compiler doesn't
recognize the word 'bool'. For historical reasons, trying to use an
undeclared identifer as a type name tends to result in a syntax error
(whereas using an undeclared identifier in, say, an assignment results
in an "undeclared identifier" message).

<OT>In C++, 'bool' is a predefined type.</OT>

You need to find a way to declare 'bool' and 'true' (and presumably
'false') *or* you need to stop using them (you can use 'int' rather
than 'bool', 0 for 'false', and 1 for 'true').

C99 introduces 'bool', 'false', and 'true', but they're defined in
<stdbool.h>. If your compiler supports it (not all do), you can add
'#include <stdbool.h>' to the top of your header file. If you don't
have <stdbool.h', you can declare 'bool' yourself. Here's how I like
to do it:

typedef enum { false, true } bool;

See also section 9 of the comp.lang.c FAQ, <http://www.c-faq.com/>.
 
M

Martin Ambuhl

You are wrong. The error messages are "cascading diagnostics." They
are the result of your first error: using the unknown type 'bool', after
which your compiler is going nuts trying to make sense of what follows.

/* header should contain */
#include <stdbool.h>
bool WriteLog(const char *lpszApp, unsigned short wType,
const char *lpszMessage);

/* implementation should contain */
#include <stdbool.h>
bool WriteLog(const char *lpszApp, unsigned short wType,
const char *lpszMessage)
{
return true;
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top