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

Cleanup clang compiler warnings #63

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@

# This is YAML - indentation levels are crucial

cache:
- C:\Users\appveyor\.tools

#---------------------------------#
# additional packages #
# build cache #
#---------------------------------#
# The AppVeyor cache allowance is way too small (1GB per account across all
# projects, branches and jobs) to be used for the dependency builds.

install:
# for the sequencer
- cinst re2c
- cmd: git submodule update --init --recursive
cache:
- C:\Users\appveyor\.tools

#---------------------------------#
# repository cloning #
Expand All @@ -23,14 +20,18 @@ init:
# Set autocrlf to make batch files work
- git config --global core.autocrlf true

clone_depth: 50
clone_depth: 5

# Skipping commits affecting only specific files
skip_commits:
files:
- 'documentation/*'
- '**/*.md'
- '.github/**'
#---------------------------------#
# additional packages #
#---------------------------------#

install:
- cmd: git submodule update --init --recursive

#---------------------------------#
# build matrix configuration #
#---------------------------------#

# Build Configurations: dll/static, regular/debug
configuration:
Expand All @@ -43,20 +44,21 @@ configuration:
environment:
# common / default variables for all jobs
SETUP_PATH: .ci-local:.ci
EPICS_TEST_IMPRECISE_TIMING: YES

matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- BASE: 3.15
CMP: vs2019
BASE: 7.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
- BASE: 7.0
CMP: gcc
BASE: 7.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- BASE: 7.0
CMP: vs2017
BASE: 7.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
- BASE: 7.0
CMP: vs2019
BASE: 3.15
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

# Platform: processor architecture
platform:
Expand Down Expand Up @@ -94,10 +96,8 @@ on_finish:
#---------------------------------#

notifications:

- provider: Email
to:
- [email protected]
on_build_success: false

- provider: GitHubPullRequest
54 changes: 28 additions & 26 deletions .github/workflows/ci-scripts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:
BASE: ${{ matrix.base }}
CMP: ${{ matrix.cmp }}
BCFG: ${{ matrix.configuration }}
WINE: ${{ matrix.wine }}
RTEMS: ${{ matrix.rtems }}
CI_CROSS_TARGETS: ${{ matrix.cross }}
EXTRA: ${{ matrix.extra }}
TEST: ${{ matrix.test }}
strategy:
Expand All @@ -40,21 +39,21 @@ jobs:
cmp: gcc
configuration: default
base: "7.0"
wine: "64"
cross: "windows-x64-mingw"
name: "7.0 Ub-20 gcc-9 + MinGW"

- os: ubuntu-20.04
cmp: gcc
configuration: static
base: "7.0"
wine: "64"
cross: "windows-x64-mingw"
name: "7.0 Ub-20 gcc-9 + MinGW, static"

- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "3.15"
wine: "64"
cross: "windows-x64-mingw"
name: "3.15 Ub-20 gcc-9 + MinGW"

- os: ubuntu-20.04
Expand All @@ -64,6 +63,12 @@ jobs:
extra: "CMD_CXXFLAGS=-std=c++11"
name: "7.0 Ub-20 gcc-9 C++11, static"

- os: ubuntu-20.04
cmp: clang
configuration: default
base: "7.0"
name: "7.0 Ub-20 clang-10"

- os: ubuntu-20.04
cmp: clang
configuration: default
Expand All @@ -75,22 +80,16 @@ jobs:
cmp: gcc
configuration: default
base: "7.0"
rtems: "4.10"
cross: "RTEMS-pc386-qemu@4.10"
name: "7.0 Ub-20 gcc-9 + RT-4.10"

- os: ubuntu-20.04
cmp: gcc
configuration: default
base: "7.0"
rtems: "4.9"
cross: "RTEMS-pc386-qemu@4.9"
name: "7.0 Ub-20 gcc-9 + RT-4.9"

- os: ubuntu-20.04
cmp: clang
configuration: default
base: "7.0"
name: "7.0 Ub-20 clang-10"

- os: macos-latest
cmp: clang
configuration: default
Expand All @@ -113,10 +112,10 @@ jobs:
cmp: gcc
configuration: static
base: "7.0"
name: "7.0 Win2019 mingw, static"
name: "7.0 Win2019 MinGW, static"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: "apt-get install"
Expand All @@ -131,11 +130,14 @@ jobs:
- name: Run main module tests
run: python .ci/cue.py test
- name: Upload tapfiles Artifact
uses: actions/upload-artifact@v2
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: tapfiles ${{ matrix.name }}
path: '**/O.*/*.tap'
if-no-files-found: ignore
- name: Collect and show test results
if: ${{ always() }}
run: python .ci/cue.py test-results

docker:
Expand All @@ -148,22 +150,20 @@ jobs:
BASE: ${{ matrix.base }}
CMP: ${{ matrix.cmp }}
BCFG: ${{ matrix.configuration }}
WINE: ${{ matrix.wine }}
RTEMS: ${{ matrix.rtems }}
EXTRA: ${{ matrix.extra }}
TEST: ${{ matrix.test }}
strategy:
fail-fast: false
matrix:
# Job names also name artifacts, character limitations apply
include:
- name: Linux centos 7
image: centos:7
cmp: gcc
configuration: default
base: "7.0"
#- name: "CentOS-7"
# image: centos:7
# cmp: gcc
# configuration: default
# base: "7.0"

- name: Linux fedora latest
- name: Fedora-latest
image: fedora:latest
cmp: gcc
configuration: default
Expand Down Expand Up @@ -196,7 +196,7 @@ jobs:
# people would rather just break all existing scripts...
[ -e /usr/bin/python ] || ln -sf /usr/bin/python3 /usr/bin/python
python --version
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: Prepare and compile dependencies
Expand All @@ -206,9 +206,11 @@ jobs:
- name: Run main module tests
run: python .ci/cue.py test
- name: Upload tapfiles Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: tapfiles ${{ matrix.name }}
path: '**/O.*/*.tap'
if-no-files-found: ignore
- name: Collect and show test results
if: ${{ always() }}
run: python .ci/cue.py test-results
8 changes: 5 additions & 3 deletions p2pApp/gwmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace pva = epics::pvAccess;

extern int p2pReadOnly;

namespace {
namespace p2pgw {
Copy link
Member

@mdavidsaver mdavidsaver Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this causing a warning?

Anonymous namespaces date to C++98. This is the c++ equivalent of static functions, also effecting special symbols for classes.

Copy link
Member

@mdavidsaver mdavidsaver Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking symbols in an anonymous namespace were not specified to have internal linkage until c++11, but in practice clang, gcc, and msvc have done so for many years.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, they're supported but annoyingly warned about:

../gwmain.cpp:245:57: warning: non-type template argument referring to function 'iocsh_drop' with internal linkage is a C++11 extension [-Wc++11-extensions]
        epics::iocshRegister<const char*, const char*, &iocsh_drop>("drop", "client", "channel");
                                                        ^~~~~~~~~~
../gwmain.cpp:205:6: note: non-type template argument refers to function here
void iocsh_drop(const char *client, const char *channel)
     ^

This PR is about cleaning up compiler warnings, and on macOS with Clang-15 I'm getting several of the above from both gwmain.cpp and qsrv.cpp.

An alternative approach would be to turn off those c++11-extensions warnings, preferably in the Base build configuration files. The following local PoC works for me, but it would have to be compiler-specific, maybe even dependent on the GCC & Clang versions:

diff --git a/p2pApp/Makefile b/p2pApp/Makefile
index 602518b..6a27152 100644
--- a/p2pApp/Makefile
+++ b/p2pApp/Makefile
@@ -6,6 +6,7 @@ include $(TOP)/configure/CONFIG
 #=============================
 
 USR_CPPFLAGS += -I$(TOP)/common
+USR_CXXFLAGS += -Wno-c++11-extensions
 
 PROD_HOST = p2p
 


pvd::StructureConstPtr schema(pvd::getFieldCreate()->createFieldBuilder()
->add("version", pvd::pvUInt)
Expand Down Expand Up @@ -235,10 +235,12 @@ void gwcr(int lvl, const char *client, const char *channel)
}
}

}// namespace
} // namespace p2pgw


int main(int argc, char *argv[])
{
using namespace p2pgw;
try {
pva::refTrackRegistrar();

Expand Down Expand Up @@ -280,7 +282,7 @@ int main(int argc, char *argv[])
lvl = pva::logLevelDebug;
else if(arg.debug==3)
lvl = pva::logLevelTrace;
else if(arg.debug>=4)
else // arg.debug>=4
lvl = pva::logLevelAll;
SET_LOG_LEVEL(lvl);

Expand Down
10 changes: 6 additions & 4 deletions pdbApp/qsrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ long dbLoadGroup(const char* fname)
}
}

namespace {
namespace qsrv {

void dbLoadGroupWrap(const char* fname)
{
Expand Down Expand Up @@ -124,16 +124,18 @@ void dbgl(int lvl, const char *pattern)
}
}

void QSRVRegistrar()
} // namespace qsrv

static void QSRVRegistrar()
{
using namespace qsrv;

QSRVRegistrar_counters();
pva::ChannelProviderRegistry::servers()->addSingleton<PDBProvider>("QSRV");
epics::iocshRegister<int, const char*, &dbgl>("dbgl", "level", "pattern");
epics::iocshRegister<const char*, &dbLoadGroupWrap>("dbLoadGroup", "jsonfile");
}

} // namespace

unsigned qsrvVersion(void)
{
return QSRV_VERSION_INT;
Expand Down
7 changes: 2 additions & 5 deletions testApp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ PROD_LIBS += $(EPICS_BASE_IOC_LIBS)

TESTPROD_HOST += testweak
testweak_SRCS += testweak.cpp
testweak_LIBS += Com
TESTS += testweak

TESTPROD_HOST += testtest
Expand Down Expand Up @@ -57,14 +56,12 @@ testpvalink_LIBS += qsrv

TESTPROD_HOST += testgroupconfig
testgroupconfig_SRCS += testgroupconfig
testgroupconfig_LIBS += qsrv pvAccess pvData
testgroupconfig_LIBS += $(EPICS_BASE_IOC_LIBS)
testgroupconfig_LIBS += qsrv
TESTS += testgroupconfig

TESTPROD_HOST += testdbf_copy
testdbf_copy_SRCS += testdbf_copy
testdbf_copy_LIBS += qsrv pvAccess pvData
testdbf_copy_LIBS += $(EPICS_BASE_IOC_LIBS)
testdbf_copy_LIBS += qsrv
TESTS += testdbf_copy
endif

Expand Down
3 changes: 3 additions & 0 deletions testApp/check_consist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ namespace pvd = epics::pvData;
namespace pva = epics::pvAccess;

namespace {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
struct Destroyer {
pvd::Destroyable::shared_pointer D;
Destroyer(const pvd::Destroyable::shared_pointer& d) : D(d) {}
~Destroyer() { if(D) D->destroy(); }
};
#pragma GCC diagnostic pop

struct Releaser {
pva::Monitor::shared_pointer& mon;
Expand Down
Loading