FAQ Database Discussion Community


How can I portably send a C struct through a network socket?

c,portability
Suppose I have a C struct defined as follows : typedef struct servData { char max_word[MAX_WORD]; char min_word[MAX_WORD]; int word_count ; } servSendData ; where 'MAX_WORD' could be any value. Now if I have an instance of this structure : servSendData myData ; And if I populate this instance and...

put libraries inside exe folder in Linux

c++,linux,shared-libraries,portability
I'm trying to make a portable Linux application where all required libraries are included inside the folder. But if I just put them in the folder next to the executables, it saiys it cant find the libraries. So how can I ship an application that contains all required libaries inside...

Portability concern

c,struct,portability
I have written a program that does all sorts of processing and write/reads the results in a file. This "result" is in a struct like this struct res { char id; char* values; int count; long samplenumber; }; and let's say I write/ read with functions like these write( file,...

Portable solution to loop through a directory recursively in bash 3.2

shell,unix,sh,portability
I want to loop recursively through every file and directory below an specified path and echo that file/directory's owner and name. I found this question to be a good reference, but I would like to know if there is a bash 3.2 portable and simpler solution to the problem. A...

mixing openssl API and BSD sockets API

c,sockets,unix,openssl,portability
I'm writing a client that must deal with both ordinary http protocol and also https for secure connections. For ordinary http connections, I should use basic socket I/O functions such as send(), recv() and so on. But for https connections, I should use SSL_read(), SSL_write and other functions from the...

Portability Bug between Windows and Unix of \r\n (CRLF) and \n (LF)?

windows,unix,portability,line-endings
When i wrote a code for Shell Script in windows platform #!/bin/bash a=20 b=10 sum=`expr $a + $b` echo $sum but tried to execute it on UNIX platform it gave me error '20\r': command not found because Windows file ends with /r/n while UNIX file ends with /n. Any Idea...

Problems with RXTX in Windows 7, but not in Windows 8

java,windows,windows-7,portability,rxtx
I'm working on a project which uses RXTX. I export it as an exacutable jar and it is in a folder like: MainFolder - lib - RXTXcomm.jar - ... more jars - logs - config.properties - App.jar <-- Executable jar In my computer (Windows 8.1) works perfectly, but it has...

Is it safe to use Bash 4 features in news scripts?

bash,portability
Bash4 offers some nice features like globstar, associative arrays, the mapfile builtin etc. Will it greatly decrease the portability of my scripts if I make use of these features? Is it safer to stick to Bash 3?...

Segmentation fault on one Linux machine but not another with C++ code

c++,linux,segmentation-fault,portability
I have been having a peculiar problem. I have developed a C++ program on a Linux cluster at work. I have tried to use it home on an Ubuntu 14.04 machine, but the program, which is composed of 6 files: main.hpp,main.cpp (dependent on) sarsa.hpp,sarsa.cpp (class Sarsa) (dependent on) wec.hpp,wec.cpp, does...

Portable XAML Styles in a Class Library

c#,wpf,visual-studio,xaml,portability
So I have an application with a style put directly into the App.xaml file as such: <Application x:Class="Test.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Startup="OnStartup"> <Application.Resources> <Style x:Key="SpecialButtonStyle" TargetType="Button"> <Setter Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> <Setter Property="OverridesDefaultStyle" Value="true"/>...

Fail to compile a python script with dependencies

python,compilation,dependencies,executable,portability
I have a tiny (70 lines) python script and I need an executable which includes all the dependencies of the script. It should be usable on windows, where python-magic is only usable in connection with cygwin. Now I've tried to use Nuitka, which gives me a 6MB executable, however it's...

fread(), solaris to unix portability and use of uninitialised values

c,linux,memory,stack,portability
Valgrind found the following error and I, after reading the documentation, the code and other questions in here couldn't figure it out why. Valgrind: first warning ~$ valgrind --vgdb=yes --vgdb-error=0 --read-var-info=yes --leak-check=yes --track-origins=yes debitadmin* debitadmin ==20720== Conditional jump or move depends on uninitialised value(s) ==20720== at 0x4013BC6: initialise (dbg.c:199) ==20720==...

C - get type alignment portably

c,types,alignment,portability
I'm writing really small interpreter for a very simple language, which allows for simple structure definitions (made of other structures and simple types, like int, char, float, double and so one). I want fields to use as little alignment as possible, so using max_align_t or something similar is out of...

tilde expansion when evaluating $PATH

bash,portability,path-variables,tilde-expansion
On my system* cd # move to home mkdir tempdir PATH="$PATH:~/tempdir" # put tempdir in path touch tempdir/tempscript echo -e '#!/bin/bash\necho h' > tempdir/tempscript # write script chmod u+x tempdir/tempscript # make executable tempscript # execute will find the script tempdir/tempscript and print h. However, if we echo $PATH, we...