Is there fmemopen() in MinGW - file-io

I'm trying to compile some code that uses the fmemopen function in MinGW. I found out that this function is not available MinGW. I need a function equivalent to fmemopen().
Are there any alternative functions that I can use?

there are no fmemopen equivalents on win32 because of missing functionality in the kernel, I think cygwin implements it using a temp file like this one: https://github.com/kespindler/python-tesseract/blob/master/util-fmemopen.c

Related

Ordinal 343 not found Win32 VC++ exports

I'm writing Windows CE API compatibility wrapper for Win32. It just wraps coredll.dll calls into Win32 ones. So, I made coredll project in Visual Studio, then I did a lot of exports in .def file like here:
WaitForSingleObject #497
WaitForMultipleObjects #498
SuspendThread #499
ResumeThread #500
SetThreadContext #502
ReadProcessMemory #506
WriteProcessMemory #507
All Windows CE programs are using ordinal to call function, so I defined appropriate ordinal in .def file for each function. See the full source code here: https://github.com/feel-the-dz3n/WinCeCompatLayer
But when I try to link this library and call function from it, Windows says that ordinal 343 not found in COREDLL.DLL.
Error appears even if 343 is defined, so it seems like the problem is in using VC++ or in exports.
P.S.: My library currently uses Windows 10 functions, so it may throw some errors on another versions of Windows
dumpbin coredll.dll /exports - output
Weird, but the reason was line from exports.def below:
DSA_Clone #1853
It's related to WinAPI, so I don't really know the reason.

autotools conditional linking

How to use different static library in ld, depending on version installed in the system ?
I need to link my program with esnacc lib which may exists as:
/usr/lib/x86_64-linux-gnu/libcxxasn1.a
or
/usr/local/lib/libc++asn1.a
Write an m4 macro that tries to find the right version of the library.
Set a variable use that variable to link your program against it.

Can I write LLVM pass using add_llvm_library, not add_llvm_loadable_module?

I'd write new transform pass related to some function optimization, and contribute it into LLVM.
But Writing an LLVM Pass was described using as dynamic LLVM loadable modules (.so extensions).
I want to write LLVM pass using add_llvm_library, not add_llvm_loadable_module in CMakeLists.txt.
Can I do it? If yes, how?
While I'm unsure why would you want this, this documentation section probably answers your question. Just replace add_library() call from that code snippet with add_llvm_library().
You can also develop your pass in-tree. For this, place your sources somewhere in lib/Analysis and then list them in lib/Analysis/CMakeLists.txt. This way your pass would be compiled into LLVM itself.
From my POV it is much more convenient to develop a pass out of source tree using add_llvm_loadable_module(), though.

How to use SQLite library in D language program on Windows?

How to use SQLite3 library in D language program on Windows?
I found a similar question with Ubuntu, but it didn't work in my case.
import std.stdio, std.string, etc.c.sqlite3;
void main () {
sqlite3* db;
auto ret = sqlite3_open (toStringz("mydb.s3db"), &db);
writeln (ret);
}
As I assume, the sqlite3.d is some kind of header to the real SQLite3 library. I've got an sqlite3.dll, but I have no idea about how to link it with my program. pragma works only with lib formate (like pragma(lib, "sqlite3")).
Maybe I should use the SQLite sources, but how is it possible to compile it together with D code? Or is it better to find some way to convert dll to lib?
What is a general method to solve such problems in D?
Or is it better to find some way to convert dll to lib?
Yes. From the question Statically linking SQLite with DMD (Windows x86), just run the .dll file through implib with the /system switch (linking with the resulting .lib file will still result in dynamic linkage and a dependency on the .dll file).
You can also compile the sqlite source (with modification) using Digital Mars C copmiler which will then give you an object file you can statically link.

How to get the functions (adresses) from a .DLL (Windows) to call them from Masm32

Im writing a Compiler for a Pascal-like language which converts the program in Masm32 (and then to a .exe). My goal is to let the coder include Windows Libraries (.DLL). So I need to read out the functionnames and the jump adresses first for correct compiler warnings. (function not defined...)
Is there a way to do this? I heard that each Win32 function has a magic number (0xXXXXXXXX) which is the adress to it which then can be called with call 0xXXXXXXXX
Masm32 comes with .inc files that include most of the Windows API functions and structures. Perhaps you can leverage those?