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: eliminate compilaton error due to the #define private public macro in all unittests #4733

Merged
merged 7 commits into from
Jul 19, 2024

Conversation

kirk0830
Copy link
Collaborator

@kirk0830 kirk0830 commented Jul 18, 2024

Reminder

  • Have you linked an issue with this pull request?
  • Have you added adequate unit tests and/or case tests for your pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #4673

Unit Tests and/or Case Tests for my changes

  • A unit test is added for each new feature or bug fix.

What's changed?

  • enclose the #define private public and #define protected public with #undef private and #undef protected.
  • eliminate the impact of #define private public on gtest and gmock
  • remove unnecessary inclusion of header <sstream> which is known to cause compilation crash with #define private public-like macro

Any changes of core modules? (ignore if not applicable)

  • Example: I have added a new virtual function in the esolver base class in order to ...

@kirk0830 kirk0830 changed the title Fix: eliminate compilaton error due to the #define private public macro in esolver_dp Fix: eliminate compilaton error due to the #define private public macro in unittest of esolver_dp Jul 18, 2024
@AsTonyshment
Copy link
Collaborator

It seems there are still some issues with the compilation...

@kirk0830 kirk0830 marked this pull request as draft July 18, 2024 10:33
@AsTonyshment
Copy link
Collaborator

Based on my local experiments, it is necessary to move all

#include "gmock/gmock.h" 
#include "gtest/gtest.h" 

statements before #define private public. This way, the compilation can succeed. @Cstandardlib Maybe you can have a try.

@Cstandardlib
Copy link
Collaborator

I tested on my machine with oneAPI 2024.2 and encountered many similar errors in tests:
image

It seems to be a systemic problem.
What they all have in common is the use of macros like #define private public. Seems that Access specifiers defined before gtest header is included will violate inner definition of gtest.

@AsTonyshment
Copy link
Collaborator

@Cstandardlib So I mean you have to deal with all these files, and move #define private public backwards.

@mohanchen mohanchen requested review from Cstandardlib and AsTonyshment and removed request for Cstandardlib and AsTonyshment July 18, 2024 23:05
@kirk0830 kirk0830 marked this pull request as ready for review July 19, 2024 02:10
@kirk0830 kirk0830 changed the title Fix: eliminate compilaton error due to the #define private public macro in unittest of esolver_dp Fix: eliminate compilaton error due to the #define private public macro in all unittests Jul 19, 2024
@AsTonyshment
Copy link
Collaborator

Compilation succeed! LGTM.😀

@Cstandardlib
Copy link
Collaborator

Build passing😆Thanks!

@mohanchen mohanchen merged commit 8b8761c into deepmodeling:develop Jul 19, 2024
14 checks passed
@mohanchen mohanchen added the Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS label Jul 19, 2024
@kirk0830 kirk0830 deleted the fix-crazy-ut branch July 19, 2024 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failed on oneAPI toolchain with deepks and testing ON
4 participants