Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Pre-processor #ifndef in __published section not allowed ?



Permlink Replies: 1 - Last Post: Oct 21, 2015 5:15 PM Last Post By: Remy Lebeau (Te...
sverker johansson

Posts: 12
Registered: 9/28/08
Pre-processor #ifndef in __published section not allowed ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 21, 2015 4:11 AM
Windows 10, XE7/CX 10 64-bit and 32-bit

When I try to do as described in the release note

#ifndef _WIN64
typedef void __fastcall (__closure TContextPopupEvent)(System::TObject Sender, const System::Types::TPoint &MousePos, bool &Handled);
#else /* _WIN64 */
typedef void __fastcall (__closure TContextPopupEvent)(System::TObject Sender, System::Types::TPoint MousePos, bool &Handled);
#endif /* _WIN64 */

I get the error message

“Error creating form: Error in module frmMeasList:
Incorrect method declaration clss
TfrmMeasListForm.”

Followed by
“Error in module frmMrasList: Incorrect method declaration in class TfrmMeasListForm!

It seems that a pre-processor directives in the __published: section is not allowed. On the other hand there is no error message if #ifndef s is in public: section.

Is there any work around ?

/Sverker Johansson
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Pre-processor #ifndef in __published section not allowed ?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 21, 2015 5:15 PM   in response to: sverker johansson in response to: sverker johansson
sverker wrote:

When I try to do as described in the release note

The documentation is misleading. You can't use #ifdef statements on event
handlers that are accessible to design-time editors. The IDE does not process
such statements, only the compiler does. If you need to use different signatures
based on platform, you will have to move the handler out of the __published
section and assign it to the event in your code at runtime, eg:

class TForm46 : public TForm
{
private:
    #ifndef _WIN64
    void __fastcall FormContextPopup(TObject *Sender, TPoint &MousePos, bool 
&Handled);
    #else
    void __fastcall FormContextPopup(TObject *Sender, TPoint MousePos, bool 
&Handled);
    #endif
public:
    __fastcall TForm46(TComponent *Owner);
};
 
__fastcall TForm46::TForm46(TComponent *Owner)
    : TForm(Owner)
{
    OnContextPopup = &FormContextPopup;
}
 
#ifndef _WIN64
void __fastcall TForm46::FormContextPopup(TObject *Sender, TPoint &MousePos, 
bool &Handled)
#else
void __fastcall TForm46::FormContextPopup(TObject *Sender, TPoint MousePos, 
bool &Handled)
#endif
{
    ShowMessage(System::String().sprintf(L"Mouse at (%d,%d)", MousePos.X, 
MousePos.Y));
}


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02