472,340 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Order of definitions

Hello group!

I have a (basic, I guess) question about the order of my definitions...

I have the following (a structure to wrap the data of a thread):

/* Thread data */
typedef struct tTkThread {
/* <snip>...</snip> */

void *pRunFunc;
} TkThread;

/* Thread procedure */
typedef void (*TkThreadProcedure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedure?

If I do my definitions in the order shown above, the compiler will complain
about not knowing the TkThreadProcedure function pointer type.

If I switch the order of the function pointer typedef and the structure def,
the compiler will complain that it does not know the TkThread structure.

Thanks in advance!

-Mogens
Nov 15 '05 #1
3 1144

Mogens Heller Jensen wrote:
Hello group!

I have a (basic, I guess) question about the order of my definitions...

I have the following (a structure to wrap the data of a thread):

/* Thread data */
typedef struct tTkThread {
/* <snip>...</snip> */

void *pRunFunc;
} TkThread;

/* Thread procedure */
typedef void (*TkThreadProcedure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedure?

If I do my definitions in the order shown above, the compiler will complain
about not knowing the TkThreadProcedure function pointer type.

If I switch the order of the function pointer typedef and the structure def,
the compiler will complain that it does not know the TkThread structure.

Thanks in advance!

-Mogens


struct tTkThread;
typedef struct tTkThread TkThread;

typedef void (*TkThreadProcedure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedure pRunFunc;
};

Nov 15 '05 #2

"John Bode" <jo*******@my-deja.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

Mogens Heller Jensen wrote:
Hello group!

I have a (basic, I guess) question about the order of my definitions...

I have the following (a structure to wrap the data of a thread):

/* Thread data */
typedef struct tTkThread {
/* <snip>...</snip> */

void *pRunFunc;
} TkThread;

/* Thread procedure */
typedef void (*TkThreadProcedure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedure?

If I do my definitions in the order shown above, the compiler will
complain
about not knowing the TkThreadProcedure function pointer type.

If I switch the order of the function pointer typedef and the structure
def,
the compiler will complain that it does not know the TkThread structure.

Thanks in advance!

-Mogens


struct tTkThread;
typedef struct tTkThread TkThread;

typedef void (*TkThreadProcedure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedure pRunFunc;
};


Oh yeah, I tried something like that - but I see now that I forgot the
"struct" part of the typedef (I'm more used to C++ you see...).

I tried this in MSVC7 and it works perfectly. But it does not work in my
case - it seems the compiler is stupid/not fully compliant with the
standard. I am using the Codevision C compiler for the Atmel Atmega16
microcontroller.

Thanks for the input!

-Mogens
Nov 15 '05 #3
[In the original, Mogens Heller Jensen shows code that does not compile
because the typedef-name occurs after the point where it is needed.]
"John Bode" <jo*******@my-deja.com> wrote in message
news:11**********************@z14g2000cwz.googleg roups.com...
struct tTkThread;
typedef struct tTkThread TkThread;

typedef void (*TkThreadProcedure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedure pRunFunc;
};

In article <43***********************@nntp02.dk.telia.net>
Mogens Heller Jensen <mo****@mookid.dk> wrote:I tried this in MSVC7 and it works perfectly.
It should; it is valid Standard C (both the old 1989 ANSI/ISO
standard, and the new 1999 ISO standard).
But it does not work in my case - it seems the compiler is stupid/not
fully compliant with the standard. I am using the Codevision C compiler
for the Atmel Atmega16 microcontroller.


You might try another newsgroup, as this one (comp.lang.c) is all
about Standard C, so we can only tell you that this compiler appears
to be broken (although to be sure of that, we would have to have a
complete sample that fails to compile).

On the other hand, you might also try removing all the "typedef"s
entirely. Remember that in C, typedef does not define types. It
just gives you a new name for an existing type. The above
can be rewritten as:

/* think of the keyword "struct" as meaning "type"; your type is
named TkThread */
struct TkThread {
...
void (*pRunFunc)(struct TkThread *pThis);
};

All you have to do is write out the "type" keyword each time,
spelling it "wrong": "STRange spelling for User-defined abstraCt
Type", or "struct".
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 15 '05 #4

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

Similar topics

14
by: Joerg Schuster | last post by:
Hello, according to http://mail.python.org/pipermail/tutor/2001-July/007246.html the order of function definitions does matter in python....
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure,...
39
by: Nicolas Fleury | last post by:
In the following example: class MyMetaclass(type): pass class MyBaseType(object): __metaclass__ = MyMetaclass class MyType(MyBaseType): x = 4...
0
by: Derrick | last post by:
I've created a suite of custom controls/components. I have 3 assemblies, as follows: - Definitions.dll: This contains classes and interfaces...
4
by: dtwalter | last post by:
Is it possible to ORDER BY a SubSelect? I don't see why it wouldn't be, but I'm having some trouble. Hopefully it's just a simple error in syntax...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers -...
6
by: Együd Csaba | last post by:
Hi All, I'd like to dump out my database using plain text format. Everything is ok, but the bytea filds. Restoring the dump file (using <<psql...
2
by: elein | last post by:
Yes, I vacuumed. Reproduced on both 7.3.2 and 7.5. Brain dead java beans want order by clauses in views that they use. my view is: select...
4
by: Frederick Gotham | last post by:
What do you think of the following code for setting and retrieving the value of bytes in an unsigned integer? The least significant bit has index...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...

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.