I want to have one XPO, and have the same code work on AX4 and AX5. I am looking for a precompiler directive to check the version, sort of like:
#if define AX4
thisCode(...)
#else
thatCode(...)
#endif
It looks like the SysDataExpImp macro library may have a version based macro called expFormat which you could use like this:
#SysDataExpImp
#if.expFormat('EXPFORMAT VER. 5.0')
info('Microsoft Dynamics AX 2009');
#endif
#if.expFormat('EXPFORMAT VER. 4.01')
info('Microsoft Dynamics AX 4.0 SP1');
#endif
You could also use a macro that is only found in AX 2009. The AotExport macro library has macros for each type of AOT object and Data Sets were introduced in 2009:
#AotExport
#if.expDataSet
info('Microsoft Dynamics AX 2009');
#endif
#ifnot.expDataSet
info('older than Microsoft Dynamics AX 2009');
#endif
Related
I use Visual Studio 2017 with ReSharper 2017.2 as the code editor for an embedded project. I managed to configure all but one thing:
How do I make VS/R# ignore that specific keyword, _Interrupt1? (this error causes other side effects).
I tried to add it as a preprocessor definition (Project's properties -> C/C++ -> Preprocessor -> Preprocessor Definitions), but it doesn't help.
I am not sure about R#, but in VS you could try to define globally:
#ifdef __INTELLISENSE__
#define _Interrupt1
#endif
to hide _Interrupt1 from Intellisense parsing.
For completeness, thanks to #Hans Passant, use __RESHARPER__ for RS
I have two version of code and I need to switch them as work need to compile each one while keeping two version on an IAR project. I find something like "compile switch" but I don't know how is it doing. Is there anyone tell me a keyword or an advice that can I search?
You can use C preprocessor #define feature to toggle between code versions and use IAR EWARM project's Defined Symbols feature to enable a list of #defines in a specific header file (for example: defines.h) that will be included in all C files.
defines.h
#if defined(PROD_VERSION)
#define SOFTWARE_VERSION_PRODUCT ("1.0-release")
//...whetever specific #defines meant for the release version, for example...
//#define ENABLE_RF_STUB
#define USE_SERIAL_CTS_RTS
#elif defined(TEST_VERSION)
#define SOFTWARE_VERSION_PRODUCT ("1.0-test")
//...whetever specific #defines meant for the test version, for example...
#define ENABLE_RF_STUB
#define USE_SERIAL_CTS_RTS
#elif defined(DEBUG_VERSION)
#define SOFTWARE_VERSION_PRODUCT ("1.0-debug")
//...whetever specific #defines meant for the debug version, for example...
#define ENABLE_RF_STUB
//#define USE_SERIAL_CTS_RTS
#endif
in rf.c
#include "defines.h"
void rfInit(void)
{
#ifndef ENABLE_RF_STUB
//init RF here
#endif
}
In serial.c
#include "defines.h"
CPU_BOOLEAN isCtsRts()
{
#ifdef USE_SERIAL_CTS_RTS
return HAL_SERIAL.isCtsRts();
#else
return DEF_TRUE; //bypass CtsRts check
#endif
}
In your project option > C/C++ Compiler > Preprocessor > Defined symbols: add PROD_VERSION if you want the release version, or add TEST_VERSION if you want the test version or add DEBUG_VERSION if you want the debug version.
You can only choose one of the three configurations above only as IAR will only compile one version via the project compilation. Unless you can create a batch build script to allow building all the three versions under different output files created with three different project setups.
IAR has a configuration in toolbar Project > Edit_Configuration
It makes you set version "switches" via set these tool and it is possible to set preprocessor command for each setup.
I've been using PostgreSQL hooks for some time now, and yesterday I wanted to try to add my own hook to test something(and for fun).
So I looked up ExecutorStart_hook to see what are the things I would need to do in order to get my own hook into PostgreSQL.
In execMain.c it is pretty straight forward, first define the hook
ExecutorStart_hook_type ExecutorStart_hook = NULL;
then use it in ExecutorStart(...);.
In executor.h we define the hook type first, and then we import the hook variable.
typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags);
extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
Where are importing this hook variable from? I don't see it anywhere else except in execMain.c, and I don't see a PGDLLEXPORT there.
On non-windows platforms, that does nothing.
On windows, PGDLLIMPORT's meaning changes based on whether the PostgreSQL server is being compiled, or an extension. The headers are written from the perspective of an extension, which is why it says PGDLLIMPORT.
If you look at the definition of PGDLLIMPORT in src/include/port/win32.h:
#ifdef BUILDING_DLL
#define PGDLLIMPORT __declspec (dllexport)
#else /* not BUILDING_DLL */
#define PGDLLIMPORT __declspec (dllimport)
#endif
... you'll see that if BUILDING_DLL is set, we expand it to __declspec(ddlexport). So it exports the symbol from the server binary. We only set BUILDING_DLL when compiling postgres.exe; its name a bit unfortunate. It's like that because on Windows you're usually exporting symbols from DLLs for use in applications, not vice versa like in postgres.
If BUILDING_DLL is not set, we define PGDLLIMPORT to __declspec(dllimport), importing the symbol from the server binary into whatever's linking to it.
So ... when postgres includes executor.h it exports the symbol. When you include executor.h in your extension DLL project, it imports the symbol.
All this is necessary because of how DLL linkage works on win32/PE. On ELF platforms (Linux, BSD, etc) and Mach-O (Mac OS X), none of it is necessary.
I am working on the source code of a Unix-based kernel. I noticed that the last line of each source code file (.c or .h) is a specific line with the following format:
__SRCVERSION( "$URL: ... $ $Rev: 219996 $" )
The URL points to the web address of the same file. I'm wondering what does that mean, and what is it actually for? Would it be any problem if I delete this line from all of my source code files?
Macros like this are often used to embed versioning information into binaries when they are compiled. They can be updated automatically when fetched out of a source control system with appropriate rules. Removing them shouldn't cause any harm, but you will lose the benefit of being able to search a binary to identify which versions of your source files were used to compile it.
As #Keith Thompson says below, it may also be possible to configure your build to not embed the information. Below is an example of the macro definition taken from here (different systems are likely to have different definitions). You can see that it uses the __USESRCVERSION definition to decide which version of the __SRCVERSION macro is used:
#ifndef __USESRCVERSION
#define __SRCVERSION(id)
#else /* __USESRCVERSION */
#ifdef __QNXNTO__
#if defined __SRCVERSION
#undef __SRCVERSION
#endif /*__SRCVERSION */
#define __SRCVERSION(id) \
__asm__(".section .ident,\"SM\",#progbits,1"); \
__asm__(".asciz " #id); \
__asm__(".previous");
#endif /* __QNXNTO__ */
#endif /* __USESRCVERSION */
I have an application that target a minimum platform of 10.5, and it compiles fine with SDK 10.6 or 10.7.
However, when compiling with an old version of xcode with 10.5 SDK, compilation fails and requires some extra #import (why it does I'm not sure, but it does). When I import the OpenGL header, I get an error about some types being unresolved. Adding #import <CarbonCore/Endian.h> fixes the problem (that's where the missing symbols are located).
I do not want to perform the #import unless absolutely necessary, and in particular not do it when compiling with 10.6 or 10.7.
I know how to check if I'm using a SDK that is superior to a given version, like so:
#if MAC_OS_X_VERSION_10_5 > MACS_VERSION_MIN_REQUIRED
// Mac > 10.5 code here
#endif
Problem is testing the reverse condition has proven to be non-trivial as all the later version of the SDK have all the defines found in earlier versions.
I'd like to find the equivalent of:
#if COMPILING_WITH_10_5_OR_EARLIER
blah
#endif
Surely, there must be an easy way I've overlooked
https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/cross_development/Using/using.html
#if __MAC_OS_X_VERSION_MAX_ALLOWED > 1050 // note use of 1050 instead of __MAC_10_5
# include <security/pam_appl.h>
#else
# include <pam/pam_appl.h>
#endif
You can write:
#ifndef MAC_OS_X_VERSION_10_6
#include <CarbonCore/Endian.h>
#endif
which will include <CarbonCore/Endian.h> if (and only if) the MAC_OS_X_VERSION_10_6 macro is not defined.