[LLVMdev] Portable I/O

Chris Lattner clattner at apple.com
Fri Feb 12 09:51:48 PST 2010


On Feb 12, 2010, at 8:45 AM, Samuel Crow wrote:

> Hello Óscar,
> 
> The problem with that idea is that they require a pointer to a FILE structure.  This file structure is included from stdio.h which has macros and conditional compilation all over the place.  There are no constructors in these libraries to call and, as such, they are platform dependent.  Is there any way to link in an external type definition to an opaque type?  We'd need to include some equivalent of stdio.h into the bitcode.

I think that the point is that you can define your own standard runtime interfaces:

void *myopen(const char*path) {
  return fopen(path, ...);
}

That way you're not exposed to libc differences, you have a standard interface that you define.

-Chris





More information about the llvm-dev mailing list