From caaf99d3ad52bb6c60cf52218a6e470c0141a4ce Mon Sep 17 00:00:00 2001 From: Josh Stillerman Date: Mon, 12 Jul 2021 15:54:46 -0400 Subject: [PATCH] Fix: remove #pragma once from the code User reported that #pragma once, which is a nonstandard feature is not supported by their compiler. As it is 'nonstandard' it seemed sensible to revert to #ifndef _FILENAME_EXT instead --- _include/P2WMutex.hpp | 5 ++++- _include/P2WSem.hpp | 5 ++++- _include/P2WThread.hpp | 5 ++++- _include/_mdsshr.h | 6 ++++-- _include/int128.h | 4 +++- configure.ac | 4 +++- deploy/gen_messages.py | 7 +++++-- include/Xmds/XmdsWaveform.h | 4 +++- include/camshr.h | 4 +++- include/dbidef.h | 4 +++- include/dcl.h | 4 +++- include/mdsshr.h | 5 +++-- include/ncidef.h | 4 +++- include/status.h | 4 +++- include/strroutines.h | 4 +++- include/tdishr.h | 4 +++- include/treeshr.h | 4 +++- include/usagedef.h | 4 +++- include/xmdsshr.h | 4 +++- mdsdcl/mdsdclthreadstatic.h | 4 +++- mdsshr/mdsshrp.h | 4 +++- mdsshr/mdsthreadstatic.h | 4 +++- mdstcpip/mdsIo.h | 4 +++- mdstcpip/mdsipshr/mdsipthreadstatic.h | 4 +++- servershr/Job.h | 4 +++- tdishr/tdithreadstatic.h | 5 ++++- testing/testing.h | 4 +++- treeshr/treeshr_xnci.h | 5 ++++- treeshr/treethreadstatic.h | 5 ++++- 29 files changed, 96 insertions(+), 32 deletions(-) diff --git a/_include/P2WMutex.hpp b/_include/P2WMutex.hpp index 2e780fe90f..da9a336c92 100644 --- a/_include/P2WMutex.hpp +++ b/_include/P2WMutex.hpp @@ -1,4 +1,6 @@ -#pragma once +#ifndef _P2WMUTEX_HPP +#define _P2WMUTEX_HPP + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -280,3 +282,4 @@ class P2WCond }; static_assert(sizeof(pthread_cond_t) == sizeof(P2WCond), "Size is not correct"); #endif +#endif // ifndef _P2WMUTEX_HPP diff --git a/_include/P2WSem.hpp b/_include/P2WSem.hpp index 2e5cc8f314..40c0f68a8d 100644 --- a/_include/P2WSem.hpp +++ b/_include/P2WSem.hpp @@ -1,4 +1,6 @@ -#pragma once +#ifndef _P2WSEM_HPP +#define _P2WSEM_HPP + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -70,3 +72,4 @@ class P2WSem } }; static_assert(sizeof(sem_t) == sizeof(P2WSem), "Size is not correct"); +#endif // ifndef _P2WSEM_HPP diff --git a/_include/P2WThread.hpp b/_include/P2WThread.hpp index c6270281d8..8cde968cd3 100644 --- a/_include/P2WThread.hpp +++ b/_include/P2WThread.hpp @@ -1,4 +1,6 @@ -#pragma once +#ifndef _P2WTHREAD_HPP +#define _P2WTHREAD_HPP + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -348,3 +350,4 @@ class P2WThread } #endif // PTHREAD }; +#endif // ifndef _P2WTHREAD_HPP diff --git a/_include/_mdsshr.h b/_include/_mdsshr.h index 6ee15497a8..bc69e63e6f 100644 --- a/_include/_mdsshr.h +++ b/_include/_mdsshr.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef __MDSSHR_H +#define __MDSSHR_H #include #include #include @@ -19,4 +20,5 @@ struct sockaddr; static returns(*method) args = NULL; \ MDSSHR_LOAD_LIBROUTINE(method, lib, method, on_error) -extern int _LibGetHostAddr(const char *hostname, const char *service, struct sockaddr *sin); \ No newline at end of file +extern int _LibGetHostAddr(const char *hostname, const char *service, struct sockaddr *sin); +#endif // ifndef __MDSSHR_H \ No newline at end of file diff --git a/_include/int128.h b/_include/int128.h index 23d79d68af..6dbc8a7ce5 100644 --- a/_include/int128.h +++ b/_include/int128.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _INT128_H +#define _INT128_H #include #include #include @@ -379,3 +380,4 @@ static inline int int128_div(const int128_t *x, const int128_t *d, int128_minus(ans, ans); return 1; } +#endif // ifndef _INT128_H \ No newline at end of file diff --git a/configure.ac b/configure.ac index 4ec864598c..e57ec3fae3 100644 --- a/configure.ac +++ b/configure.ac @@ -1206,7 +1206,8 @@ dnl Here we define all custom autoheader adds to mdsconfig.h.in dnl add here what goes on tom of mdsconfig.h AH_TOP( -#pragma once +#ifndef _MDSCONFIG_H +#define _MDSCONFIG_H #ifdef _MSC_VER #define __attribute__(...) #define EXPORT __declspec(dllexport) @@ -1248,6 +1249,7 @@ AH_VERBATIM([_WIN32], [ dnl add here what goes on bottom of mdsconfig.h AH_BOTTOM( #endif // _MSC_VER else +#endif // ifndef _MDSCONFIG_H ) diff --git a/deploy/gen_messages.py b/deploy/gen_messages.py index 8cbeb36967..fa6e4484cc 100755 --- a/deploy/gen_messages.py +++ b/deploy/gen_messages.py @@ -135,7 +135,8 @@ class %(fac)s%(msgnam)s(%(fac)sException):%(depr)s """ inc_head = """ -#pragma once +#ifndef _{base}_{ext} +#define _{base}_{ext} #include """ @@ -296,7 +297,8 @@ def gen_include(root, filename, faclist, msglistm, f_test): print(filename) with open("%s/include/%sh" % (sourcedir, filename[0:-3]), 'w') as f_inc: add_c_header(f_inc, filename) - f_inc.write(inc_head) + parts = filename.upper().split('.') + f_inc.write(inc_head.format(base=parts[0],ext=parts[1])) for f in root.iter('facility'): facnam = f.get('name') facnum = int(f.get('value')) @@ -352,6 +354,7 @@ def gen_include(root, filename, faclist, msglistm, f_test): if not facnam in pfaclist: pfaclist.append(facnam) msglist.append(msg) + f_inc.write("#endif") # gen_msglist(): diff --git a/include/Xmds/XmdsWaveform.h b/include/Xmds/XmdsWaveform.h index 48ffb41744..409d4b22e5 100644 --- a/include/Xmds/XmdsWaveform.h +++ b/include/Xmds/XmdsWaveform.h @@ -41,7 +41,8 @@ Management. ----------------------------------------------------------------------------*/ -#pragma once +#ifndef _XMDSWAVEFORM_H +#define _XMDSWAVEFORM_H #include #ifndef _Xm_h #include @@ -210,3 +211,4 @@ extern void XmdsWaveformUpdate(Widget w, XmdsWaveformValStruct *x, extern void XmdsWaveformSetWave(Widget w, int count, float *x, float *y, Boolean *select, Boolean *pendown, Boolean autoscale, Boolean defer_update); +#endif //ifndef _XMDSWAVEFORM_H diff --git a/include/camshr.h b/include/camshr.h index d36ada0ee4..20868e4350 100644 --- a/include/camshr.h +++ b/include/camshr.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _CAMSHR_H +#define _CAMSHR_H extern int CamBytcnt(unsigned short *iosb); extern int CamError(int *xexp, int *qexp, unsigned short *iosb_in); @@ -35,3 +36,4 @@ typedef struct } CamKey; extern int CamXlateLogicalname(char *Name, CamKey *key); +#endif diff --git a/include/dbidef.h b/include/dbidef.h index 8f3ffe03c0..ecf0cecf39 100644 --- a/include/dbidef.h +++ b/include/dbidef.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _DBIDEF_H +#define _DBIDEF_H /* VAX/DEC CMS REPLACEMENT HISTORY, Element DBIDEF.H */ /* *3 1-APR-1991 17:29:45 TWF "Add readonly open" */ /* *2 16-FEB-1990 10:28:18 TWF "Add itmlst struct" */ @@ -33,3 +34,4 @@ typedef struct dbi_itm void *pointer; int *return_length_address; } DBI_ITM; +#endif \ No newline at end of file diff --git a/include/dcl.h b/include/dcl.h index ecf5f4c1eb..7834aff20f 100644 --- a/include/dcl.h +++ b/include/dcl.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _DCL_H +#define _DCL_H #include extern int mdsdclAddCommands(const char *name_in, char **error); @@ -20,3 +21,4 @@ extern int mdsdcl_do_command_extra_args(char const *command, char **prompt, char *(*getline)(), void *getlineinfo); extern int cli_get_value(void *ctx, const char *name, char **value); extern int cli_present(void *ctx, const char *name); +#endif \ No newline at end of file diff --git a/include/mdsshr.h b/include/mdsshr.h index 6b5d43f028..111de223bf 100644 --- a/include/mdsshr.h +++ b/include/mdsshr.h @@ -1,5 +1,5 @@ -#pragma once - +#ifndef _MDSSHR_H +#define _MDSSHR_H #define MdsCOMPRESSIBLE 3 #include #include @@ -159,3 +159,4 @@ extern "C" #ifdef __cplusplus } #endif +#endif diff --git a/include/ncidef.h b/include/ncidef.h index 2bd136c45a..e37ce6986c 100644 --- a/include/ncidef.h +++ b/include/ncidef.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _NCIDEF_H +#define _NCIDEF_H /************************************** NCIDEF.H - definitions of constants used in item list arguments to the @@ -93,3 +94,4 @@ typedef struct nci_itm void *pointer; int *return_length_address; } NCI_ITM; +#endif diff --git a/include/status.h b/include/status.h index 77f8b8567b..72a2eec55a 100644 --- a/include/status.h +++ b/include/status.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _STATUS_H +#define _STATUS_H #include #define STATUS_H(x) x #define FALSE 0 @@ -34,3 +35,4 @@ #define GOTO_IF_NOT_OK(MARK, CHECK) \ if (IS_NOT_OK((status = (CHECK)))) \ goto MARK; +#endif \ No newline at end of file diff --git a/include/strroutines.h b/include/strroutines.h index 514bb26d1b..3cb6e21c73 100644 --- a/include/strroutines.h +++ b/include/strroutines.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _STRROUTINES_H +#define _STRROUTINES_H #include @@ -51,3 +52,4 @@ static void __attribute__((unused)) free_d(void *ptr) #define INIT_AND_FREED_ON_EXIT(var, dtype) \ INIT_AS_AND_FREED_ON_EXIT(var, ((mdsdsc_d_t){0, dtype, CLASS_D, NULL})) #endif +#endif \ No newline at end of file diff --git a/include/tdishr.h b/include/tdishr.h index 004f16dc3e..7007168401 100644 --- a/include/tdishr.h +++ b/include/tdishr.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _TDISHR_H +#define _TDISHR_H #include #include #include @@ -31,3 +32,4 @@ extern int _TdiIntrinsic(void **ctx, opcode_t opcode, int narg, struct descriptor_xd *out_ptr); extern int CvtConvertFloat(void *invalue, uint32_t indtype, void *outvalue, uint32_t outdtype, uint32_t options); +#endif \ No newline at end of file diff --git a/include/treeshr.h b/include/treeshr.h index a908fb9bfa..4b6259f9a7 100644 --- a/include/treeshr.h +++ b/include/treeshr.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _TREESHR_H +#define _TREESHR_H /********** define this in case user code is checking it ************/ @@ -378,3 +379,4 @@ extern "C" #ifdef __cplusplus } #endif +#endif \ No newline at end of file diff --git a/include/usagedef.h b/include/usagedef.h index 5e1620eae3..a4bf5dd7a7 100644 --- a/include/usagedef.h +++ b/include/usagedef.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _USAGEDEF_H +#define _USAGEDEF_H /* USAGEDEF.H ************************************ Node Usage definitions @@ -28,3 +29,4 @@ TYPEDEF(1){TreeUSAGE_ANY = 0, TreeUSAGE_STRUCTURE = 1, TreeUSAGE_ACTION = 2, #undef TYPEDEF #undef ENDDEF #define TreeUSAGE_NONE TreeUSAGE_STRUCTURE +#endif diff --git a/include/xmdsshr.h b/include/xmdsshr.h index 6fca4efffd..e897f4e469 100644 --- a/include/xmdsshr.h +++ b/include/xmdsshr.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _XMDSSHR_H +#define _XMDSSHR_H #include #include #include @@ -74,3 +75,4 @@ extern EXPORT Pixmap *XmdsUsageGrayIcons(); extern EXPORT WidgetClass xmdsWaveformWidgetClass; extern EXPORT XmdsWaveformClassRec xmdsWaveformClassRec; +#endif diff --git a/mdsdcl/mdsdclthreadstatic.h b/mdsdcl/mdsdclthreadstatic.h index 985fe93c5b..3cc9894479 100644 --- a/mdsdcl/mdsdclthreadstatic.h +++ b/mdsdcl/mdsdclthreadstatic.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _MDSDCLTHREADSTATIC_H +#define _MDSDCLTHREADSTATIC_H #include "../mdsshr/mdsthreadstatic.h" #include "dcl_p.h" @@ -18,3 +19,4 @@ typedef struct #define DCL_DOCS DCLTHREADSTATIC_VAR->docs extern DEFINE_GETTHREADSTATIC(DCLTHREADSTATIC_TYPE, DclGetThreadStatic); +#endif // ifndef _MDSDCLTHREADSTATIC_H \ No newline at end of file diff --git a/mdsshr/mdsshrp.h b/mdsshr/mdsshrp.h index 804df40f72..5ca65f8a22 100644 --- a/mdsshr/mdsshrp.h +++ b/mdsshr/mdsshrp.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _MDSSHRP_H +#define _MDSSHRP_H #include @@ -22,3 +23,4 @@ extern int MDSUdpEventAstMask(char const *eventName, extern int MDSUdpEventCan(int eventid); extern int MDSUdpEvent(char const *eventName, int bufLen, char const *buf); extern int LibSFree1Dd(struct descriptor *out); +#endif //indef _MDSSHRP_H \ No newline at end of file diff --git a/mdsshr/mdsthreadstatic.h b/mdsshr/mdsthreadstatic.h index 69f8f4a1d8..738062c7e3 100644 --- a/mdsshr/mdsthreadstatic.h +++ b/mdsshr/mdsthreadstatic.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _MDSTHREADSTATIC_H +#define _MDSTHREADSTATIC_H #include #include #include @@ -59,3 +60,4 @@ typedef struct #define MDS_FIS_ERROR MDSTHREADSTATIC_VAR->librtl_fis_error extern DEFINE_GETTHREADSTATIC(MDSTHREADSTATIC_TYPE, MdsGetThreadStatic); +#endif // ifndef _MDSTHREADSTATIC_H diff --git a/mdstcpip/mdsIo.h b/mdstcpip/mdsIo.h index 56bfca1156..54a33f304a 100644 --- a/mdstcpip/mdsIo.h +++ b/mdstcpip/mdsIo.h @@ -1,5 +1,6 @@ -#pragma once +#ifndef _MDSIO_H +#define _MDSIO_H #ifndef DOXYGEN // hide this part from documentation typedef enum @@ -128,3 +129,4 @@ typedef union { } #endif #endif // DOXYGEN end of hidden code +#endif // ifndef _MDSIO_H diff --git a/mdstcpip/mdsipshr/mdsipthreadstatic.h b/mdstcpip/mdsipshr/mdsipthreadstatic.h index cdc21dd368..29a15ffd72 100644 --- a/mdstcpip/mdsipshr/mdsipthreadstatic.h +++ b/mdstcpip/mdsipshr/mdsipthreadstatic.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _MDSIPTHREADSTATIC_H +#define _MDSIPTHREADSTATIC_H #include "../mdsshr/mdsthreadstatic.h" #include "../mdsip_connections.h" @@ -16,3 +17,4 @@ typedef struct #define MDSIP_CONNECTIONS MDSIPTHREADSTATIC_VAR->connections extern DEFINE_GETTHREADSTATIC(MDSIPTHREADSTATIC_TYPE, MdsIpGetThreadStatic); +#endif // ifndef _MDSIPTHREADSTATIC_H diff --git a/servershr/Job.h b/servershr/Job.h index a571836b54..dc1aa79990 100644 --- a/servershr/Job.h +++ b/servershr/Job.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _JOB_H +#define _JOB_H #include #include @@ -262,3 +263,4 @@ static void Job_cleanup(int status, int jobid) j = Job_pop_by_conid(conid); } while (j); } +#endif // ifndef _JOB_H \ No newline at end of file diff --git a/tdishr/tdithreadstatic.h b/tdishr/tdithreadstatic.h index 08f0a7a13b..82854b6e45 100644 --- a/tdishr/tdithreadstatic.h +++ b/tdishr/tdithreadstatic.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef _TDITHREADSTATIC_H +#define _TDITHREADSTATIC_H + #include "../mdsshr/mdsthreadstatic.h" #include "tdirefzone.h" @@ -72,3 +74,4 @@ typedef struct #define TDI_BALANCE (TDI_STACK.balance.all) extern DEFINE_GETTHREADSTATIC(TDITHREADSTATIC_TYPE, TdiGetThreadStatic); +#endif // ifndef _TDITHREADSTATIC_H diff --git a/testing/testing.h b/testing/testing.h index 768808c977..5c4b4ef0db 100644 --- a/testing/testing.h +++ b/testing/testing.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef _TESTING_H +#define _TESTING_H #include #include @@ -211,3 +212,4 @@ _Pragma("GCC diagnostic ignored \"-Wcatch-value\"") TEST1(correct_exception_caught); \ } #endif +#endif // ifndef _TESTING_H diff --git a/treeshr/treeshr_xnci.h b/treeshr/treeshr_xnci.h index e1ca933157..076236cfb0 100644 --- a/treeshr/treeshr_xnci.h +++ b/treeshr/treeshr_xnci.h @@ -1,5 +1,7 @@ -#pragma once +#ifndef _TREESHR_XNCI_H +#define _TREESHR_XNCI_H + #include #ifdef __cplusplus extern "C" @@ -72,3 +74,4 @@ extern "C" #ifdef __cplusplus } #endif +#endif // ifndef _TREESHR_XNCI_H diff --git a/treeshr/treethreadstatic.h b/treeshr/treethreadstatic.h index a89f0c8c29..c2e627dc8d 100644 --- a/treeshr/treethreadstatic.h +++ b/treeshr/treethreadstatic.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef _TREETHREADSTATIC_H +#define _TREETHREADSTATIC_H + #include "../mdsshr/mdsthreadstatic.h" #include "treeshrp.h" @@ -41,3 +43,4 @@ extern DEFINE_GETTHREADSTATIC(TREETHREADSTATIC_TYPE, TreeGetThreadStatic); extern void **TreeCtx(); extern EXPORT int TreeUsePrivateCtx(int onoff); +#endif // ifndef _TREETHREADSTATIC_H