StructOp Handbook
Contents Examples Commands

Lib zlib

Console program108 lines of .st181 lines of generated C
Program output
47 bytes packed into 17, unpacked 47 (rc 0 = Z_OK 0): hello hello hello hello hello hello hello hello
CRC-32 3106698858, version known: true
On this page

The .st files#

intent.st
structop {
    type_app {
        exec = {
            lang     = "C"
            standard = "c11"
        }
    }

    lib_provider {
        C_lang = {
            source  = "StructOp/c"
            version = "@latest"
        }
        Zip = {
            source  = "C/zlib"
            version = "@latest"
        }
    }
}

Input, plan and generated C#

bind/zlib.bind.st · hints for structop bind
bind/zlib.bind.st · hints for structop bind
bind "zlib" {
    header  = "zlib.h"
    package = "zlib"
    prefix  = ["compress", "uncompress", "crc32", "zlibVersion", "Z_"]
}
structop plan
structop plan
  # program.app will be created
  + program.app (.structop/build/app)
      + ability.value.input
      + ability.value.packed
      + ability.value.unpacked
      + ability.value.rc
      + ability.value.crc
      + ability.value.version
      + ability.set.Fill
      + ability.compress.Pack
      + ability.uncompress.Unpack
      + ability.crc32.Check
      + ability.zlibVersion.Version
      + ability.print.Show
      + ability.print.Crc

Plan: 1 to add, 0 to change, 0 to destroy.
Generated main.c

To inspect this generated file, select C in intent.st, initialize the project and export its source.

Export locally
structop init
structop apply -source -no-run
Try it
structop bind bind/zlib.bind.st    # from the repository root
cd lib-zlib    # a folder holding the .st files above
structop init
structop plan
structop apply