Skip to content

Commit ad8b726

Browse files
authored
Avoid defining the visibility attribute on Windows (#1673)
1 parent 426eb52 commit ad8b726

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# testthat (development version)
22

3+
* Fixed a warning in R >=4.2.0 on Windows that occurred when using the C++
4+
testing infrastructure that testthat provides (#1672).
5+
36
* You can now configure the behaviour of the implicit
47
`devtools::load_all()` call performed by `devtools::test()` in your
58
package DESCRIPTION file (#1636). To disable exports of internal

inst/include/testthat/testthat.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,9 @@
1212
* Force 'testthat' to be disabled by defining TESTTHAT_DISABLED.
1313
* TESTTHAT_DISABLED takes precedence.
1414
* 'testthat' is disabled on Solaris by default.
15-
*
16-
* Hide symbols containing static members on gcc, to work around issues
17-
* with DLL unload due to static members in inline functions.
18-
* https://github.com/r-lib/devtools/issues/1832
1915
*/
2016
#if defined(__GNUC__) || defined(__clang__)
2117
# define TESTTHAT_ENABLED
22-
# define TESTTHAT_ATTRIBUTE_HIDDEN __attribute__ ((visibility("hidden")))
23-
#else
24-
# define TESTTHAT_ATTRIBUTE_HIDDEN
2518
#endif
2619

2720
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) || defined(__sun) || defined(__SVR4)
@@ -32,6 +25,20 @@
3225
# define TESTTHAT_DISABLED
3326
#endif
3427

28+
/*
29+
* Hide symbols containing static members on gcc, to work around issues
30+
* with DLL unload due to static members in inline functions. This seems to only
31+
* affect Linux. We never define this attribute on Windows, as MinGW has a known
32+
* issue with this visibility attribute and ignores it with a warning.
33+
* https://github.com/r-lib/devtools/issues/1832
34+
* https://github.com/r-lib/testthat/issues/1672
35+
*/
36+
#if (defined(__GNUC__) && !defined(__MINGW32__)) || defined(__clang__)
37+
# define TESTTHAT_ATTRIBUTE_HIDDEN __attribute__ ((visibility("hidden")))
38+
#else
39+
# define TESTTHAT_ATTRIBUTE_HIDDEN
40+
#endif
41+
3542
#ifndef TESTTHAT_DISABLED
3643

3744
# define CATCH_CONFIG_PREFIX_ALL

0 commit comments

Comments
 (0)