GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - coddra/c-plu: Funky little extra features for C

BranchesTags
Open more actions menu

Latest commit

 

History

685 Commits
685 Commits

Folders and files

NameName
Last commit message
Last commit date
.builds
.builds
 
 
doc
doc
 
 
test
test
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
arg.h
arg.h
 
 
attr.c
attr.c
 
 
cc.h
cc.h
 
 
configure
configure
 
 
cproc-README.md
cproc-README.md
 
 
cproc.1
cproc.1
 
 
decl.c
decl.c
 
 
driver.c
driver.c
 
 
eval.c
eval.c
 
 
expr.c
expr.c
 
 
init.c
init.c
 
 
main.c
main.c
 
 
map.c
map.c
 
 
ops.h
ops.h
 
 
pp.c
pp.c
 
 
qbe.c
qbe.c
 
 
runtests
runtests
 
 
scan.c
scan.c
 
 
scope.c
scope.c
 
 
stmt.c
stmt.c
 
 
targ.c
targ.c
 
 
token.c
token.c
 
 
tree.c
tree.c
 
 
type.c
type.c
 
 
utf.c
utf.c
 
 
utf.h
utf.h
 
 
util.c
util.c
 
 
util.h
util.h
 
 

Repository files navigation

C-PLU

Funky little extra features to C to make it even more fun.

c-plu is based on the cproc compiler by Michael Forney. See cproc-README.md for more details.

Currently added features:

  • auto dereferencing
  • dot syntax function call with auto lifting
  • auto union wrapping

If any features break backwards compatibility, please let me know by opening an issue.

Auto dereferencing

Given a pointer to a struct/union, using the . operator with an identifier will automatically dereference the pointer.

struct location {
    int x;
    int y;
};

int main(void) {
    struct location *loc = malloc(sizeof(struct location));

    // works just fine
    loc.x = 0;
    loc.y = 0;

    return 0;
}

DotCall

Dot syntax function call with auto lifting (DotCall for short) allows to locate the first parameter of a function call before the function. Auto lifting refers to automatically taking the addres of that argument, if possible.

int add(int x, int y) {
    return x + y;
}

int* inc(int *x) {
    ++*x;
    return x;
}

int main(void) {
    int x = 0;

    // works just fine
    x = x.add(34).add(35);

    // works just fine because of auto lifting
    x.inc().inc();

    // would not work, as cannot take address of literal
    //(0).inc();

    // auto dereferencing makes this possible
    int *y = malloc(sizeof(int));
    *y = y.add(10);

    return 0;
}

Union wrapping

When an expression is used where a union is expected, and the union has a member of the type of the expression, the expression is automatically wrapped into a union.

union u {
    int x;
    double y;
}

union u a = 2.5; // instead of {.y = 2.5}

void f(union u a) { }

void main() {
    union u a = 5; // instead of {.x = 5}
    f(10.0); // instead of (union u){.y = 10.0}
}

About

Funky little extra features for C

Resources

Readme
License
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.