Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several WIN32 macro check problem in cuda module. #1568

Merged
merged 1 commit into from
Aug 20, 2016

Conversation

ShiningPluto
Copy link
Contributor

It is obvious that no one care about the CUDA part of PCL!

@SergioRAgostinho SergioRAgostinho added this to the pcl-1.8.1 milestone Jul 14, 2016
@SergioRAgostinho SergioRAgostinho added the needs: code review Specify why not closed/merged yet label Jul 14, 2016
@SergioRAgostinho
Copy link
Member

@taketwo Based on this seems true. But looking at our pcl_macros.h, I see both definitions being used. Should we suggest to change to

#if defined WIN32 || defined _WIN32

?

@taketwo
Copy link
Member

taketwo commented Aug 19, 2016

Usage of these macros in pcl_macros.h is inconsistent, see e.g. lines 172 and 180. Unfortunately, I'm not a Windows user, so can not comment on which one is the preferred.

@SergioRAgostinho
Copy link
Member

From what I'm seeing here and here I'm more convinced that _WIN32 is the standard way of doing it and WIN32 is something that normally also works because

  1. The user included some windows headers which defined it
  2. MSVC also appears to add it although it's not exactly a standard

@UnaNancyOwen any relevant comments you might give us on this discussion?

Nevertheless, I have the feeling this should be good to merge.

@SergioRAgostinho SergioRAgostinho added status: ready to merge and removed needs: code review Specify why not closed/merged yet labels Aug 19, 2016
@UnaNancyOwen
Copy link
Member

It is correct that @SergioRAgostinho said.
Microsoft-specific predefined macros | MSDN Library

#include <iostream>

int main()
{
    // Defined as 1 when include header that WIN32 is defined (such as windows.h), or set define WIN32 in preprocessor definition.
    // "WIN32" is user-defined flags.
    std::cout << "WIN32 : ";
#ifdef WIN32
    std::cout << "Defined" << std::endl;
#else
    std::cout << "Undefined" << std::endl;
#endif

    // Defined as 1 when compilation target is 32-bit ARM, 64-bit ARM, x86, or x64.
    // "_WIN32" is compiler-defined flags.
    // That is, _WIN32 is always defined by compiler when using MSVC.
    std::cout << "_WIN32 : ";
#ifdef _WIN32
    std::cout << "Defined" << std::endl;
#else
    std::cout << "Undefined" << std::endl;
#endif

    return 0;
}

MSVC output is following.

WIN32 : Undefined
_WIN32 : Defined

@SergioRAgostinho
Copy link
Member

Super nice explanation. Thanks @UnaNancyOwen

@SergioRAgostinho SergioRAgostinho merged commit c688333 into PointCloudLibrary:master Aug 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants