473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

UCHAR undeclared

Hi all,

I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;

and a function:

void foo( bufferType typeIn ){
...
}
when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?

thanks a lot,
tirzan

Apr 7 '06 #1
7 4674
tirzan wrote:
I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing
Don't.

Show us the /exact/ code. If you don't know what's wrong, how
can you know what's relevant?
I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;

and a function:

void foo( bufferType typeIn ){
...
}
when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?


I /guess/ you haven't included the declaration of `foo` or
of `bufferType` in the compilation unit containing `main`,
but since I can't see your code, it's just a guess.

--
Chris "not a Tuvela" Dollin
"To say that the human is thus and so is almost always to lie automatically."
Apr 7 '06 #2
tirzan wrote:

Hi all,

I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;

and a function:

void foo( bufferType typeIn ){
...
}

when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?


Not really.

/* BEGIN new.c */

typedef enum {
UCHAR,
SCHAR,
INT
} bufferType;

void foo(bufferType typeIn)
{
typeIn;
}

int main(void)
{
foo(SCHAR);
return UCHAR;
}

/* END new.c */
--
pete
Apr 7 '06 #3
tirzan wrote:
Hi all,

I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing I have a:
Hello Mr Mechanic, my car won't start. Here are the sparc plugs and the
ignition key, what is wrong with my car?

Always provide a small *complete* example illustrating the problem. I
would say compilable, but obviously if as is the case here the problem
is you can't compile it then that is not appropriate.
typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;
You do know that typdef does not really create a new type in C don't you.
and a function:

void foo( bufferType typeIn ){
So for this function there is nothing to stop any integer from being
passed in, you are not limited to the enumerations.
...
}
when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?


Yes, the definition of UCHAR is not in scope at the point where you call
foo. Either it is before you define it, in a different file, or
something. Had you provided your actual code people could tell you the
actual problem.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Apr 7 '06 #4
tirzan wrote:
summarizing I have a: typedef enum{
UCHAR,
SCHAR,
INT
} bufferType; and a function: void foo( bufferType typeIn ){
...
} when in the main I call the function foo, with for example:
foo(UCHAR);
I have an error: "UCHAR undeclared" any hint?


Please post your real code. I believe you have misdiagnosed your
problem. The following code incorporates *all* the information you ahve
given. Please see if it produces the diagnostic that you report.

typedef enum
{
UCHAR,
SCHAR,
INT
} bufferType;

void foo(bufferType typeIn)
{
/* ... */
}

int main(void)
{
foo(UCHAR);
return 0;
}

Apr 7 '06 #5
tirzan wrote:
summarizing I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType; any hint?


thanks everybody, I solved the problem: other UCHARs somewhere in the
code (with different enum order), then the solution was:

typedef enum{
t_UCHAR,
t_SCHAR,
t_INT
} bufferType;

in the code. Now it runs... not really elegant... but it compile ;-)

thank you guys, and sorry if i didn't put the code, but I was working
with at least 10 files open, I'm not so sadistic to let you read so
much code for me ;-)
bye,
tirzan

Apr 7 '06 #6
tirzan wrote:
Hi all,

I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;

and a function:

void foo( bufferType typeIn ){
...
}
when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?

thanks a lot,
tirzan

Typedef is no declaration ,only

BufferType typeIn;

somewhere in your scope is a declaration.

Typedef defines a type(as the name suggests),
and can be used to declare a variable.
Apr 7 '06 #7
Sjouke Burry wrote:

tirzan wrote:
Hi all,

I'm trying to reuse a piece of code in C, but I have some problems, I
hope you can help me.

summarizing I have a:

typedef enum{
UCHAR,
SCHAR,
INT
} bufferType;

and a function:

void foo( bufferType typeIn ){
...
}
when in the main I call the function foo, with for example:

foo(UCHAR);

I have an error: "UCHAR undeclared"

any hint?

thanks a lot,
tirzan

Typedef is no declaration ,only

BufferType typeIn;

somewhere in your scope is a declaration.

Typedef defines a type(as the name suggests),
and can be used to declare a variable.


Defining a type is also a declaration.

All definitions in a translation unit are also declarations.

--
pete
Apr 8 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: W. Van Hooste | last post by:
Just starting with C, can somebody explain why this does not work or point me in the right direction? I wrote some tools and did some coding but cant seem to get this one. I DID declare my FILE...
6
by: rouble | last post by:
Hi All, Is it safe to store a uchar in a void* and then extract the uchar value out of it again ? My understanding is that the size of a void* should always be equal to or greater than the...
6
by: Peter Rothenbuecher | last post by:
Hello, when I try to compile the following code with g++ -o client client.c #include<sys/socket.h> #include<stdio.h> #include<stdlib.h> #define ADDRESS "mysocket"; #define MAXLEN 200;
2
by: grubbymaster | last post by:
Hello The problem i have is this : i want to use the following structure in a DLL that i created: typedef struct _NDIS_802_11_SSID { ULONG SsidLength; UCHAR Ssid ; } NDIS_802_11_SSID,...
11
by: therock112 | last post by:
hello I am new to C and not sure how to go about getting the following accomplished: I have the following c code, under centos ver 3.4, using gnu gcc to compile: uchar sn; // readings
7
by: michigaki | last post by:
hello, we are having problems in compiling a 'slightly' altered x264. We are always receiving a 'helloWorld' undeclared (first use this function) error. We may be commiting a very simple error but...
0
by: p.lavarre | last post by:
http://wiki.python.org/moin/ctypes now tries to answer: '''FAQ: How do I copy bytes to Python from a ctypes.Structure?''' '''FAQ: How do I copy bytes to a ctypes.Structure from Python?'''...
8
by: aneuryzma | last post by:
Hello, I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using xCode. When I add #include "openCVApp.h" I got the following error:
7
by: Adam01 | last post by:
Im using cygwin to test the code of a server I am writing. I've included sys/types.h, sys/socket.h, netdb.h, and arpa/inet.h. And this is the output.. ../../../sockets.cpp: In constructor...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.