Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: using timeSetEvent in Win64



Permlink Replies: 9 - Last Post: Aug 22, 2017 4:04 AM Last Post By: Jarek Karciarz
Jarek Karciarz

Posts: 7
Registered: 2/28/17
using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2017 2:14 AM
Hello all,

I am trying to port my SIP library to the Win64 platform. This library
uses timeSetEvent() in order to periodically send RTP packets over
udp.I know that this function is obsolete however it still works fine
with Win32.
When trying to compile for Win64 the declaration of this function
cannot be found in any header file.
I am using BCB 10.2.1
Thanks for any direction

Jarek
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2017 12:47 PM   in response to: Jarek Karciarz in response to: Jarek Karciarz
Jarek Karciarz wrote:

I know that [timeSetEvent] is obsolete

Says who?

When trying to compile for Win64 the declaration of this function
cannot be found in any header file.

It should be defined in mmsystem.h, which is already included by
windows.h by default.

--
Remy Lebeau (TeamB)
Alex Belo

Posts: 626
Registered: 10/8/06
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2017 10:00 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

I know that [timeSetEvent] is obsolete

Says who?

MS

https://msdn.microsoft.com/ru-ru/library/windows/desktop/dd757634(v=vs.85).aspx

It should be defined in mmsystem.h, which is already included by
windows.h by default.

More precisely

"Header

TimeAPI.h (include Windows.h);

Mmsystem.h on Windows Server 2008 R2, Windows 7, Windows 7, Windows
Server 2008 and Windows Vista (include Windows.h)"

--
Alex
Jarek Karciarz

Posts: 7
Registered: 2/28/17
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2017 5:05 AM   in response to: Alex Belo in response to: Alex Belo
Alex Belo wrote:

Remy Lebeau (TeamB) wrote:

I know that [timeSetEvent] is obsolete

Says who?

MS

https://msdn.microsoft.com/ru-ru/library/windows/desktop/dd757634(v=vs.85).aspx

Yes, exactly.


It should be defined in mmsystem.h, which is already included by
windows.h by default.

More precisely

"Header

TimeAPI.h (include Windows.h);

Mmsystem.h on Windows Server 2008 R2, Windows 7, Windows 7, Windows
Server 2008 and Windows Vista (include Windows.h)"

I tried to inlude directly both headers: mmsystem.h and timeapi.h. And
te compiler still complains timeSetEvent() function not found.
I'm afraid some of #defines might prevent the declaration to be visible.
Alex Belo

Posts: 626
Registered: 10/8/06
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 19, 2017 9:19 PM   in response to: Jarek Karciarz in response to: Jarek Karciarz
Jarek Karciarz wrote:

I tried to inlude directly both headers: mmsystem.h and timeapi.h. And
the compiler still complains timeSetEvent() function not found.
I'm afraid some of #defines might prevent the declaration to be
visible.

Yes, it is possible. So steps are quite obvious:

1. Search for "timeSetEvent" in text editor.
2. Search for evil #define after that.

:)

--
Alex
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 21, 2017 10:50 AM   in response to: Jarek Karciarz in response to: Jarek Karciarz
Jarek Karciarz wrote:

Jarek Karciarz wrote:

I tried to inlude directly both headers: mmsystem.h and timeapi.h.
And the compiler still complains timeSetEvent() function not found.
I'm afraid some of #defines might prevent the declaration to be
visible.

Yes, it is possible. So steps are quite obvious:

1. Search for "timeSetEvent" in text editor.
2. Search for evil #define after that.

timeSetEvent() is declared in mmsystem.h on my system. It is also
wrapped in '#ifndef MMNOTIMER', so make sure MMNOTIMER is not being
defined.

--
Remy Lebeau (TeamB)

Jarek Karciarz

Posts: 7
Registered: 2/28/17
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 21, 2017 1:55 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Jarek Karciarz wrote:

Jarek Karciarz wrote:

I tried to inlude directly both headers: mmsystem.h and timeapi.h.
And the compiler still complains timeSetEvent() function not
found. I'm afraid some of #defines might prevent the declaration
to be visible.

Yes, it is possible. So steps are quite obvious:

1. Search for "timeSetEvent" in text editor.
2. Search for evil #define after that.

timeSetEvent() is declared in mmsystem.h on my system. It is also
wrapped in '#ifndef MMNOTIMER', so make sure MMNOTIMER is not being
defined.

I have BCB 10.2.1 and RAD2007. In 10.2.1 the only header file
containing the function name is mmiscapi2.h and I cant see here any
suspicious #define. It curious that i didnt find the declaration in any
of .hpp files although mmsystem.pas contains timeSetEvent() declaration
as an external function. In RAD2007 the declaration is as Remy said
inside mmsystem.h. But RAD is nt my IDE as I compile for Win64
Jarek Karciarz

Posts: 7
Registered: 2/28/17
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 21, 2017 2:07 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Jarek Karciarz wrote:

Jarek Karciarz wrote:

I tried to inlude directly both headers: mmsystem.h and timeapi.h.
And the compiler still complains timeSetEvent() function not
found. I'm afraid some of #defines might prevent the declaration
to be visible.

Yes, it is possible. So steps are quite obvious:

1. Search for "timeSetEvent" in text editor.
2. Search for evil #define after that.

timeSetEvent() is declared in mmsystem.h on my system. It is also
wrapped in '#ifndef MMNOTIMER', so make sure MMNOTIMER is not being
defined.

Ok, I solved it. C++ 64 bit compiler is very strict. The error message
was a bit misleading to me: no matching function for call to
timeSetEvent. Problem was that my callback function should be
explicittly casted to (LPTIMECALLBACK). That solved the problem.
Thanks for assistance.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 21, 2017 2:37 PM   in response to: Jarek Karciarz in response to: Jarek Karciarz
Jarek Karciarz wrote:

Problem was that my callback function should be explicittly casted
to (LPTIMECALLBACK). That solved the problem.

If you have to cast your callback, you declared it wrong to begin with.
Fix the declaration, then a cast will not be needed.

--
Remy Lebeau (TeamB)
Jarek Karciarz

Posts: 7
Registered: 2/28/17
Re: using timeSetEvent in Win64
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 22, 2017 4:04 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Jarek Karciarz wrote:

Problem was that my callback function should be explicittly casted
to (LPTIMECALLBACK). That solved the problem.

If you have to cast your callback, you declared it wrong to begin
with. Fix the declaration, then a cast will not be needed.

Yes, thats correct.
There were some DWORD args in my declaration and they should be
DWORD_PTR. It didnt change since RAD2007, so for win32 compiler there
was no difference but for win64 it was. And that is pretty clear for me
why.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02