Okay, in some legacy code, in the .h file I have exactly this:
typedef struct MSObject
{
// this refers to the entire set of data points
double *x;
double *y;
int numValues;
// save zoomed values
double xval_start; // x[first] value in zoom window
double xval_end; // x[last] value in zoom window
int xyindex_start; // first x[index_start] in zoom window
int xyindex_end; // last x[index_end] in zoom window
double Ymin, Ymax; // within zoom window
}MSSpectrum;
// prototypes
int MSObjectReadXY(char *path, MSObject *object);
These are global, and any .c files that include this .h file and use the
MSObject contain also only global functions.
I reallllly want just to add a constructor and destructor to MSObject,
and not have to change the signature of every function that uses this
object.
I have tried every combination of classes, structs, typedefs and
otherwise but nothing will compile that will allow me to add a
constructor to this thing.
What do I need to do? 4 1543
Bryan wrote: Okay, in some legacy code, in the .h file I have exactly this: typedef struct MSObject { // this refers to the entire set of data points double *x; double *y; int numValues; // save zoomed values double xval_start; // x[first] value in zoom window double xval_end; // x[last] value in zoom window int xyindex_start; // first x[index_start] in zoom window int xyindex_end; // last x[index_end] in zoom window double Ymin, Ymax; // within zoom window
}MSSpectrum;
// prototypes int MSObjectReadXY(char *path, MSObject *object);
These are global, and any .c files that include this .h file and use the MSObject contain also only global functions.
I reallllly want just to add a constructor and destructor to MSObject, and not have to change the signature of every function that uses this object.
I have tried every combination of classes, structs, typedefs and otherwise but nothing will compile that will allow me to add a constructor to this thing.
What do I need to do?
What you need to do is just what I suggested in response to your
previous post on this subject: post a *minimal* but *complete* sample
that demonstrates the error you are getting. You can probably do just
what you want to do, assuming there's no initialization of these
structs like this:
MSObject obj = { 0, 0 /*...*/ };
Cheers! --M
Bryan a écrit : Okay, in some legacy code, in the .h file I have exactly this: typedef struct MSObject { // this refers to the entire set of data points double *x; double *y; int numValues; // save zoomed values double xval_start; // x[first] value in zoom window double xval_end; // x[last] value in zoom window int xyindex_start; // first x[index_start] in zoom window int xyindex_end; // last x[index_end] in zoom window double Ymin, Ymax; // within zoom window
}MSSpectrum;
// prototypes int MSObjectReadXY(char *path, MSObject *object);
These are global, and any .c files that include this .h file and use the MSObject contain also only global functions.
I reallllly want just to add a constructor and destructor to MSObject, and not have to change the signature of every function that uses this object.
I have tried every combination of classes, structs, typedefs and otherwise but nothing will compile that will allow me to add a constructor to this thing.
You mention ".c files". Would these happen to contain (as the name
suggests) C (and not C++) code?
"Bryan" <sp**@nospam.com> wrote in message
news:WM*******************@newssvr12.news.prodigy. com... Okay, in some legacy code, in the .h file I have exactly this: typedef struct MSObject { // this refers to the entire set of data points double *x; double *y; int numValues; // save zoomed values double xval_start; // x[first] value in zoom window double xval_end; // x[last] value in zoom window int xyindex_start; // first x[index_start] in zoom window int xyindex_end; // last x[index_end] in zoom window double Ymin, Ymax; // within zoom window }MSSpectrum;
This is different from what you showed before. (Perhaps something is
looking for "MSSpectrum"?) // prototypes int MSObjectReadXY(char *path, MSObject *object);
These are global, and any .c files that include this .h file and use the MSObject contain also only global functions.
("These"? I only see one function prototype.)
Perhaps you're compiling with a C compiler instead of a C++ compiler? I've
seen at least one compiler that assumes a .c file should be compiled as C
(whereas it would compile a .cpp file as C++ code).
I reallllly want just to add a constructor and destructor to MSObject, and not have to change the signature of every function that uses this object.
So go ahead. And you don't need to change it to a class to do so. A struct
can have a constructor and destructor, too. (Unless you're using some
REALLY old compiler!) I have tried every combination of classes, structs, typedefs and otherwise but nothing will compile that will allow me to add a constructor to this thing.
What do I need to do?
Post the code that your compiler reports an error on, and post the error
message text as well. And if you can post a complete, small example that
will cause the same error when WE compile it, we could help better. (We
can't just guess what the error is, or what the code is that generates the
error.)
-Howard
In message <WM*******************@newssvr12.news.prodigy.com> , Bryan
<sp**@nospam.com> writes Okay, in some legacy code, in the .h file I have exactly this: typedef struct MSObject { // this refers to the entire set of data points double *x; double *y; int numValues; // save zoomed values double xval_start; // x[first] value in zoom window double xval_end; // x[last] value in zoom window int xyindex_start; // first x[index_start] in zoom window int xyindex_end; // last x[index_end] in zoom window double Ymin, Ymax; // within zoom window
}MSSpectrum;
// prototypes int MSObjectReadXY(char *path, MSObject *object);
^^^^^^^^
Are you sure that's _exactly_ what's in the file?
MSObject is the struct tag, but the name of the type is MSSpectrum.
--
Richard Herring This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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#...
|
by: Brett |
last post by:
I have created a structure with five fields. I then create an array of this
type of structure and place the structure into an array element. Say index
one. I want to assign a value to field3 of...
|
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...
|
by: Steve Turner |
last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows:
typedef struct tag_scanparm
{
short...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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);"...
|
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...
|
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,...
|
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: 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...
|
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: 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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |