portability

How can I creating executable JAR with SWT that runs on all platforms?

微笑、不失礼 提交于 2019-11-28 07:39:53
SWT comes with a base JAR and one specific JAR per platform (Windows, Linux/32bit, Linux/64bit, Mac, AIX, ...). How can I create an executable JAR that will select the correct platform JAR at runtime? [EDIT] I was thinking to supply all platform JARs in a subdirectory and in main() would then modify the class loader. Has anyone already tried this? Matías Look at this, there is a code sample: Create cross platform java swt application For my current job I needed to supply an executable jar that could load jars inside itself and execute a second main(). Basically a bootstrap main() and an

Checking the gcc version in a Makefile?

被刻印的时光 ゝ 提交于 2019-11-28 06:11:39
I would like to use some gcc warning switchs that aren't available in older gcc versions (eg. -Wtype-limits). Is there an easy way to check the gcc version and only add those extra options if a recent gcc is used ? I wouldn't say its easy, but you can use the shell function of GNU make to execute a shell command like gcc --version and then use the ifeq conditional expression to check the version number and set your CFLAGS variable appropriately. Here's a quick example makefile: CC = gcc GCCVERSION = $(shell gcc --version | grep ^gcc | sed 's/^.* //g') CFLAGS = -g ifeq "$(GCCVERSION)" "4.4.3"

Swap 2 values of 2 variables without using a third variable; python

牧云@^-^@ 提交于 2019-11-28 05:48:31
问题 So, a friend of mine asked how my python programming was coming; I said I was learning a lot and that it was coming along nicely. Then my friend, a math-snob, asks me: "Can you swap the value of 2 variables without using a third variable as a temporary placeholder?" 回答1: The canonical way to swap two variables in Python is a, b = b, a Please note than this is valid whatever the "type" of a or b is (numeric, string, tuple, object, ...). Of course, it works too if both variables reference

_Pragma preprocessor operator in Visual C++

女生的网名这么多〃 提交于 2019-11-28 03:55:56
问题 Is there something like the ANSI C operator _Pragma in Visual C++? For example, I'm trying to define the following macro: #ifdef _OPENMP #define PRAGMA_IF_OPENMP(x) _Pragma (#x) #else // #ifdef _OPENMP #define PRAGMA_IF_OPENMP(x) #endif // #ifdef _OPENMP So I can circumvent compiler warnings for unknown #pragma omp ... in older GCC compilers. Is there a similar means available in VisualC++? 回答1: Yes, but it's two underscores: __pragma I'm not sure about how the omp pragma works, however, here

Which parts of the python standard library are guaranteed to be available? [closed]

时间秒杀一切 提交于 2019-11-28 03:17:37
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I'm interested to know which parts of the python standard library are absolutely guaranteed to be available, and which parts might not

How can I have a portable Emacs?

Deadly 提交于 2019-11-28 03:16:23
Is there a way run Emacs from a USB drive? I am a Windows user and I would like to be able use it on any PC without an Emacs install. Yes, the "normal" Emacs distribution for Windows is precompiled and just runs without having to do any install. Just get one of the *.zip files from the usual place , unpack it onto a USB disk, and you can use it directly. (The actual binary is inside the "bin/" directory.) The only thing you may want to do is set it up to look for ".emacs" always on the USB disk instead of on your hard drive; see (info "(emacs) Windows HOME") on how to do that. You can read

Are there fixed size integers in GCC?

≡放荡痞女 提交于 2019-11-28 03:01:35
问题 On the MSVC++ compiler, one can use the __int8 , __int16 , __int32 and similar types for integers with specific sizes. This is extremely useful for applications which need to work with low-level data structures like custom file formats, hardware control data structures and the like. Is there a similar equivalent I can use on the GCC compiler? 回答1: ISO standard C, starting with the C99 standard, adds the standard header <stdint.h> that defines these: uint8_t - unsigned 8 bit int8_t - signed 8

Why and how are C++ bitfields non-portable?

自古美人都是妖i 提交于 2019-11-28 02:53:49
问题 I've come across many comments on various questions regarding bitfields asserting that bitfields are non-portable, but I've never been able to find a source explaining precisely why. At face value, I would have presumed all bitfields merely compile to variations of the same bitshifting code, but evidently there must be more too it than that or there would not be such vehement dislike for them. So my question is what is it that makes bitfields non-portable? 回答1: Bit fields are non-portable in

How to install external libraries with Portable Python?

烂漫一生 提交于 2019-11-28 01:22:48
I can't install Python on my machine due to administrator privileges, but I did download/open Portable Python successfully. I am on a Windows 7 64-bit machine. How would I be able to use the external libraries from before, such as Numpy or Gmpy? easy_install is trying to install from source. gmpy and gmpy2 are C extensions and require the presence of a compatible C compiler and other libraries (GMP; and MPFR and MPC for gmpy2). Installing from source is frequently difficult on Windows. The installers include a precompiled version of the extension. One option is to extract the compiled binary

How to check if file exists in C++ in a portable way?

半腔热情 提交于 2019-11-27 23:46:27
问题 Currently I use this code to check if file exists on Windows and POSIX -compatible OSes (Linux, Android, MacOS, iOS, BlackBerry 10): bool FileExist( const std::string& Name ) { #ifdef OS_WINDOWS struct _stat buf; int Result = _stat( Name.c_str(), &buf ); #else struct stat buf; int Result = stat( Name.c_str(), &buf ); #endif return Result == 0; } Questions: Does this code have any pitfalls? (maybe an OS where it cannot be compiled) Is it possible to do it in a truly portable way using only C/C