# How to Wrap Fortran Types with Opaque Pointers

**URL:** <https://discourse.julialang.org/t/how-to-wrap-fortran-types-with-opaque-pointers/130252>\
**Category:** General Usage\
**Created:** [June 26, 2025, 6:55pm UTC](https://discourse.julialang.org/t/how-to-wrap-fortran-types-with-opaque-pointers/130252 "2025-06-26T18:55:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejmeitz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ejmeitz/32/45283_2.png) [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Post date:** [June 26, 2025, 6:55pm UTC](https://discourse.julialang.org/t/how-to-wrap-fortran-types-with-opaque-pointers/130252/1 "2025-06-26T18:55:40Z")

</div>

I am trying to create a wrapper for a rather large Fortran library. Many of the classes in this library have over a dozen fields and those fields are often their own classes. To avoid having to create a wrapper for all of these classes I want to use opaque pointers and factory functions to generate the classes automatically. However, in this library (and most Fortran codes I think) the objects are default constructed and then you call the factory with the first argument as the default constructed object. How can I get this empty handle in Julia so that I can actually call the factory function?

Basically I want to do:

```julia
empty_handle::Ptr{CVoid} = default_construct_my_fortran_type()
handle = from_file(empty_handle, filepath)

```
