473,395 Members | 1,972 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,395 software developers and data experts.

Odd structure

I was looking through some old legacy code that has been a pain for some
time and I found this:

typedef struct MSObject {
// Members
} MSObject;

Why would you do this? And furthermore, why, if I change it to:

class MSObject {
public:
// Members
};

do all the functions that use MSObject complain of a syntax error ')'
when I try to compile?

I would really like to replace this typedef'ed type with an object
without having to modify all the files (and there are a bunch) that use it.
Jun 8 '06 #1
2 1462
Bryan wrote:
I was looking through some old legacy code that has been a pain for some
time and I found this:

typedef struct MSObject {
// Members
} MSObject;

Why would you do this? And furthermore, why, if I change it to:

class MSObject {
public:
// Members
};

do all the functions that use MSObject complain of a syntax error ')'
when I try to compile?

I would really like to replace this typedef'ed type with an object
without having to modify all the files (and there are a bunch) that use it.


The original code with that typedef business was likely written to be
compatible with C or was written by someone unfamiliar with C++'s
changes. The first "MSObject" is the struct tag, and the second is a
the typedef name (i.e., an alias for "struct MSObject"). In C++, the
"typedef" and second "MSObject" are unnecessary, but even without them,
it can still be used as either "struct MSObject" or just "MSObject".

As for your syntax error, post a *complete* but *minimal* sample that
demonstrates the problem, and we can tell you.

Cheers! --M

Jun 8 '06 #2
Bryan wrote:
I was looking through some old legacy code that has been a pain for some
time and I found this:

typedef struct MSObject {
// Members
} MSObject;

Why would you do this?
Do what?
And furthermore, why, if I change it to:

class MSObject {
public:
// Members
};

do all the functions that use MSObject complain of a syntax error ')'
when I try to compile?
Hard to tell without any more code. Maybe the functions have
'struct MSObject' as parameter?
I would really like to replace this typedef'ed type with an object
without having to modify all the files (and there are a bunch) that use
it.


Jun 8 '06 #3

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

Similar topics

2
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
4
by: marco_segurini | last post by:
Hi, From my VB program I call a C++ function that gets a structure pointer like parameter. The structure has a field that contains the structure length and other fields. My problem is that...
8
by: Charles Law | last post by:
Can anyone suggest how I would marshal a variable length structure back from an API call. Specifically, I am looking at the WaitForDebugEvent function, which returns a DEBUG_EVENT structure. ...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
3
by: Kiran B. | last post by:
Hi, I am new to .net. I have two Data Structure Type ... Sturcture A and Structure B. Structure A Public Fname as String Public LastName as String Public City as String Public Zip as String...
14
by: Dennis | last post by:
If I have a structure like; Public Structure myStructureDef Public b() as Byte Public t as String End Structure If I pass this structure, will the values in the array b be stored on the...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
11
by: Lance | last post by:
Hi all, I've got a some structures defined as ////// <StructLayout(LayoutKind.Sequential)Public Structure GM_LayerInfo_t Public mDescription As String Public mNativeRect As GM_Rectangle_t...
4
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal...
5
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.