|
hi, everyone
recently I started a new project which needs to be written in plain C,
and I got problem with different compilers that:
I want the declaration of public APIs along with data types required to
be in some separate files, and the definition of the types in some others,
for example:
interface.h
struct _VECTOR;
/**
* there's a problem with the absence of 'struct' in function
* declaration at least in mingw2.95, but that's not the point
* of my post.
*/
void _InitVector(struct _VECTOR* pVector);
implementation.h
#include "interface.h"
/* my point is here */
typedef struct _tagVECTOR {
int a;
} _VECTOR, *_PVECTOR;
implementation.c
#include "implementation.h"
void _InitVector(struct _VECTOR* pVector)
{
pVector->a = 1; /* derefferencing pointer to imcomplete type. */
}
It seems that the compiler cannot recognize the fact that _VECTOR is a typedef
name of the struct _tagVECTOR;
By the definition of 'typedef', I know that _VECTOR declared in "interface.h"
is exactly the same entity to that in "implementation.h", although it turned
out to be a typedef name of _tagVECTOR, but it won't compile in mingw2.95 with
the error mentioned in the code above.
Revised version can solve the problem:
typedef struct _VECTOR {
int a;
} *_PVECTOR;
But I want it to be consistent with the general idea, so I revised further:
typedef struct _VECTOR {
int a;
} _VECTOR, *_PVECTOR;
It compiled with no problem, but I'm not sure if I'm lucky enough with other
compilers holding the potential issue of "typedef redefinition".
Thanks in advance.
|
|
|
|
|
Why are you posting a plain C question in a C++ / MFC forum?
That said, I think you should write
void _InitVector(_VECTOR* pVector)
instead of
void _InitVector(struct _VECTOR* pVector)
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
hi,
The joke is that because I think C is a subset of C++.
And I got problem with the absence of that 'struct':
[Error] parse error before '*'
It seems the pre-declaration can never be sighted by the compiler(mingw2.95).
|
|
|
|
|
6Qing88 wrote: And I got problem with the absence of that 'struct
Sorry I didn't read your post carefully. The problem is that you declare _VECTOR as a struct first
struct _VECTOR;
void _InitVector(struct _VECTOR* pVector);
but as a typedef later
typedef struct _tagVECTOR {
int a;
} _VECTOR, *_PVECTOR;
You can't forward declare a typedef as a struct, because it is not a struct - it is a typedef. I think it is intended to be that way (i.e. it's not the compiler but the C language specs that require it).
You can try writing this at the header (I haven't tested it)
struct _tagVECTOR;
typedef struct _tagVECTOR _VECTOR;
void _InitVector(_VECTOR * pVector);
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Your problem is that you're using struct _VECTOR in interface.h and _VECTOR == struct _tagVECTOR elsewhere. Those are two different types. It doesn't matter that you use _VECTOR in both - struct tag names are in a different namespace than type names.
Thus, in implementation.c , struct _VECTOR is incomplete. struct _tagVECTOR , aka _VECTOR is complete...but you are not referencing that type!
|
|
|
|
|
Hi all,
I am making look and feel of a Dialog same as message box can anybody tell me what font and size should i make it so that it should look exactly similar as messageBox.
Thanks
vikas da
|
|
|
|
|
You should use the MS Shell Dlg or MS Shell Dlg [^] logical fonts to have the same behavior of MS Windows dialogs. I am pretty sure that the default font size is 8 for most english users but if I remember correctly the default font size can be larger in an international installation.
Also keep in mind that although most users with 20-20 vision have the DPI set at 96, there may be individuals with DPI set at 120. You should test your messagebox dialog to ensure that it can handle all environments.
Best Wishes,
-David Delaune
|
|
|
|
|
guide me load data to combobox for vc++6.0. please. thanks
"
enum { IDD = IDD_SPOOLIMAGE_DS_PP };//gọi form
DDX_Control(pDX, IDC_TEST, value_del);
CComboBox* cb = (CComboBox*)GetDlgItem(IDC_TEST);
cb->Clear();
CString sName = "";
for(int i=0; i<10;i++)
{
cb->SetItemData(i, DWORD(i));
}
"
|
|
|
|
|
And what the problem?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
can you tell specification ? thanks . wish your help
|
|
|
|
|
If you want to add strings to Combobox you can use of:
for (int i = 0; i < m_nItems; i++)
{
m_pComboBox->InsertString(str);
}
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
why don't you use to AddString() to load data into the combo box?
|
|
|
|
|
I was Addstring() but wrong.
|
|
|
|
|
nguyen phan wrote: cb->SetItemData(i, DWORD(i));
SetItemData() is used to Set the 32-bit value associated with the specified item in a combo box. AddString() is used to add a string to the end of the list in the list box of a combo box.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
How to Invoke a Web Service using managed C++ OR VC++ .NET . provide me with some link
|
|
|
|
|
|
Did you see Web Services[^]?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
HI
how can i detect if a new ethernet cable is connected or disconnected dynamically?
can we use redundant ethernet cable so that it can takeover if the first one fails?
can we stop the communication through a port manually? i.e, enabling or disabling of a port?
Regards
pramod
|
|
|
|
|
hi experts plesae let me know how to obtain all DLLS information that depends on particular .exe file in 16 bit programs.Dependency walker is not working for 16-bit programs.iam working on vc++ 1.52...
kir_MFC
modified on Friday, January 9, 2009 1:40 AM
|
|
|
|
|
|
Use the EnumProcessModules API.
Use the GetCurrentProcess API to get the handle to the current process or OpenProcess to open an already running process.
If you want to get the dependent DLLs of an EXE that is not running, you will need to parse the EXEs internal PE structure.
PEDump is one such program.
«_Superman_»
|
|
|
|
|
Hi,
I'm loading resource>toolbar into CImageList
When i draw using imageList.draw, then the transparent is no more work
any idea?
CImageList ImgList;
COLORREF rgbTransparentColor = RGB(73,73,73);//dono what this use..
CBitmap bmp;
int bubu = bmp.LoadBitmapW(IDR_MAINFRAME);//the toolbar to be loaded
ImgList.Create(16.5,14.5,ILC_MASK | ILC_COLOR32,1,1);
ImgList.Add(&bmp, rgbTransparentColor);//put the bitmap into imagelist
CPoint ptImage(rectIcon.left + 1, rectIcon.top + 1);//get the point(position) of the rectangle to be drawn
ImgList.Draw(pDC, nIconPosi, ptImage, ILD_NORMAL);//draw the icon
good
|
|
|
|
|
karhong wrote: RGB(73,73,73);//
Is this the color in the bitmap that you want to make transperent?
|
|
|
|
|
yea.. i hope to make the imgList.Draw icons to have the background color of RGB(73,73,73)
good
|
|
|
|
|
Either I am misunderstanding you, or you are misunderstanding the API.
The transparent colour is the colour in the original bitmap that you want to become transparent.
I normally use a hideous shade of purple, or pink. I'm too manly to use them for actual display. There is nothing stopping you using a certain shade of gray (RGB(73,73,73)), but it will be less obvious when you are editing the original bitmap.
For debugging the sort of problem you have, I strongly recommend the excellent article http://www.codeproject.com/KB/applications/imageviewer.aspx[^] by PJ Arends.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|