473,893 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 (*TkThreadProce dure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedu re?

If I do my definitions in the order shown above, the compiler will complain
about not knowing the TkThreadProcedu re 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 1205

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 (*TkThreadProce dure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedu re?

If I do my definitions in the order shown above, the compiler will complain
about not knowing the TkThreadProcedu re 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 (*TkThreadProce dure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedu re pRunFunc;
};

Nov 15 '05 #2

"John Bode" <jo*******@my-deja.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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 (*TkThreadProce dure)(TkThread *pThis);
My question is: How do I change the type of pRunFunc from void* to
TkThreadProcedu re?

If I do my definitions in the order shown above, the compiler will
complain
about not knowing the TkThreadProcedu re 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 (*TkThreadProce dure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedu re 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.go oglegroups.com. ..
struct tTkThread;
typedef struct tTkThread TkThread;

typedef void (*TkThreadProce dure)(TkThread *pThis);

struct tTkThread {
...
TkThreadProcedu re pRunFunc;
};

In article <43************ ***********@nnt p02.dk.telia.ne t>
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)(str uct 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
6303
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. Does anyone know a trick to avoid this? Is there a way to "declare" functions without defining them?
7
3677
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, type-checks, conversions, value-validations, metadata etc. And i have things to offer, and to request. And a lot of ideas, but who needs them.... here's an example (from type_struct.py):
39
2956
by: Nicolas Fleury | last post by:
In the following example: class MyMetaclass(type): pass class MyBaseType(object): __metaclass__ = MyMetaclass class MyType(MyBaseType): x = 4 y = 5 z = 6 Is there any way to modify MyMetaclass to keep the order of x,y,z somewhere?
0
887
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 that are common to the other 2 assemblies. There are no controls/components in this dll - ControlA.dll: Contains the "root" control. Only has a reference to the Definitions dll
4
7572
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 and somebody can tell me. Here's what I'm trying to do... I've got two tables: Table1: TestData Filename Bird FileB Blue FileA Circle FileC
60
8338
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 - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
6
3558
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 -f LO_TRY_INSERT_BYTEA.sql tmp7>>) it sends an error message like psql:LO_TRY_INSERT_BYTEA.sql:14: ERROR: Bad input string for type bytea Trying dumping with copy commands it sends this error: psql:LO_TRY_COPY_BYTEA.sql:13: lost synchronization with server, resetting
2
2858
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 .... from bigtable b left join lookuptable l order by bigkey desc;
4
2221
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, then the next least significant bit has index 1, and so on. The code computes at runtime the byte-order of the unsigned integer, but alas it would be better if it could be determined at compile-time. The code potentially invokes undefined behaviour if an unsigned integer contains padding bits....
0
9982
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11243
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10837
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10927
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9645
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7173
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5858
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4280
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.