Jump to content

GetCurrentTime() compilation error due to Winbase.h

- - - - -

  • Please log in to reply
3 replies to this topic

#1
harshareddy75

harshareddy75

    Newbie

  • Members
  • PipPip
  • 20 posts
Hi,

I have a class GetCurrentTime and constructors GetCurrentTime() and ~GetCurrentTime().

When I try to compile it I get a compilation error -
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2523: 'namespace::GetCurrentTime::~GetTickCount' : destructor type mismatch

and some other similar errors.

I found out that my program includes Winbase.h which has a line
#define GetCurrentTime() GetTickCount()

which is causing all the errors.

Is there any workaround for this error without me having to change the class name (as that would be very troublesome). Thanks for the help.

Regards,
Harsha

#2
julmuri

julmuri

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
You could use undef, ie:
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif

I would just change the class name though, that might break some code.
std::string s("oberq zhpu?");std::for_each(s.begin(),s.end(),[&](char&c){c=~c;c=~c-0x01/(~(c|0x20)/0x0D*0x02-0x0B)*0x0D;});std::cout<<s;

#3
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,717 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
As long as you don't call GetCurrentTime anywhere, you can do a project-wide replace with your new class name. I forget the actual dialog box, but if you hit CTRL+H it should be an option on there. I really do not recommend undefining GetCurrentTime(). Seriously.
sudo rm -rf /

#4
harshareddy75

harshareddy75

    Newbie

  • Members
  • PipPip
  • 20 posts
Thank you for your replies. I guess I will just change the class name.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users