Giter Club home page Giter Club logo

openbsd_list_macro_printer's Introduction

C macro and function call finder

A Clang plugin for creating printers for OpenBSD list macro declarations.

Quickstart

Download prerequisites

The following instructions assume an Ubuntu 22.04 LTS operating system:

  • Ninja

    sudo apt install ninja-build
  • CMake 3.29.1 (click here for download and install instructions)

  • LLVM 17 and Clang 17:

    wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
    sudo apt install llvm-17 clang-17 libclang-17-dev

Building the Clang plugin

  1. Configure the plugin:

    cmake -S . -B build -G "Ninja Multi-Config" \
        -D CMAKE_C_COMPILER=<path to clang-17 compiler> \
        -D CMAKE_CXX_COMPILER=<path to clang++-17 compiler> \
        -D Clang_DIR=<path to ClangConfig.cmake> \
        -D LLVM_DIR=<path to LLVMConfig.cmake>
  2. Build the plugin:

    cmake --build build --config=Release

Usage

Assuming you are currently at the project root, then you can run the shared library on the following platforms as follows:

Ubuntu:

/usr/bin/clang-17 \
    -fplugin=./build/lib/Debug/libopenbsd_list_macro_printer.so \
    -fsyntax-only \
    test/slist.c

MacOS:

/opt/homebrew/opt/llvm@17/bin/clang \
    -fplugin=./build/lib/Debug/libopenbsd_list_macro_printer.dylib \
    -fsyntax-only \
    test/slist.c

The output should be:

{
    struct entry * __openbsd_list_iterator;
    SLIST_FOREACH(__openbsd_list_iterator, &head, entries) {
        printf("%d", __openbsd_list_iterator->a);
        printf("%d", __openbsd_list_iterator->b);
        printf("%s", __openbsd_list_iterator->s);
        printf("%s", __openbsd_list_iterator->t);
    }
}

Development

We recommend downloading the clangd C/C++ language server to ease development.

This project also provides a .clang-format file for formatting. If you would like to contribute, please ensure that you've formatted your code with clang-format before committing it. Assuming you are on Ubuntu, you can download clang-format with the following command:

sudo apt install clang-format

openbsd_list_macro_printer's People

Contributors

pappasbrent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.