"wtfC!?" is a playful language extension for C and C++ that introduces unconventional and humorous macros to replace common programming constructs. This project aims to add a touch of creativity and humor to C/C++ programming, offering an alternative way to write code that might appeal to developers looking for a unique coding experience.
Warning
wtfC!? was made for fun, thus, do not use it for professional use. But yeah, you have to be insane enough to use this on serious projects.
import <stdio.h>
main(i32 argc, string argv[])
begin
nothing;
i32* test = make(i32, 10);
test[9] = 100;
echo(test[9]);
echo("\nHello, damn world!\r\n");
for ever;
end
If you are using the macro import
, you should preprocess your source file first before compiling. For example:
gcc -x c -E -include src/wtfc.wtfch -o full_example_prep.c examples/full_example.wtfc
gcc -w -o full_example full_example_prep.c && rm full_example_prep.c
./full_example
You can skip the pre-preprocessing phase if you don't use the import
macro for file inclusion.
-
import
: Replace#include
with a more unconventional syntax.import <stdio.h> import <math.h>
-
main
: Simplify the main function declaration.main() begin return 0; end
-
make
: A macro for dynamic memory allocation usingmalloc
. Inspired from Golang'smake
.// Allocates memory for array with 10 items. i32* array = make(i32, 10);
-
repeat
: Introduce a loop construct with a humorous loop variable name.repeat(n, 10) begin echo("["); echo(n); echo("] Hello!\r\n"); end
The first parameter is an integer and can be accessed to track the current iteration count.
-
ever
: Define an infinite loop construct usingfor(;;)
.// Self explanatory infinite loop for ever begin // You code here end
-
elif
: Combineelse
andif
for brevity. Inspired from Python'sElif
.i32 num = 0; if(num == 0) { } elif(num == 1) { } elif(num == 2) { } else { }
-
nothing
: Define a function pointer with an empty lambda-like function.// Yeah, it does nothing... nothing;
-
echo
: A versatile macro for printing values with type awareness. This will cause a lot of warnings, you can use the-w
parameter ongcc
.echo("Hello, world!"); echo('\n'); echo(3.14f);
-
begin
andend
: Replace{
and}
for defining code blocks.// Basic block using the begin and end keyword. begin ... end
-
random
: Randomly executed a statement based on the random seed.random echo("Randomly executed!"); else echo("Random wasn't executed.")
-
Integer Types: Macros for defining integer types with different sizes. There integer types are mostly inspired from Rust's primitive data types. This integer types includes:
i8
,i16
,i32
,i64
,u8
,u16
,u32
,u64
,rune
,string
, andusize
. -
unless
: Counter-part forif
statement that only executes its body if the condition is false.unless(false) begin echo("Hi, `unless` statement was executed.") end
-
true
andfalse
: Self explanatory boolean values. -
sub
: Macro for creating a procedure or subroutine.// Declares a function named `say` // that takes a string parameter sub(say, void, string message) begin echo(message); end
-
Operators:
add
,minus
,divide
,times
,not
,is
,less
,lesseq
,greater
,greatereq
,and
,or
, andas
. -
Pointer and Address operators:
address
andaddressof
.
Contributions to "wtfC!?" are welcome! If you have an idea for a new macro or want to improve existing ones, please follow these guidelines:
-
Fork the repository.
-
Create a new branch for your feature or bug fix.
git checkout -b feature/your-feature-name
-
Make your changes and commit them with a clear commit message.
git commit -m "Add new macro: your_macro_name"
-
Push your branch to your fork.
git push origin feature/your-feature-name
-
Submit a pull request.
- Provide a clear title and description for your pull request.
- Include information about the changes made and the motivation behind them.
-
Follow the coding style.
- Ensure that your changes adhere to the project's coding style.
- Maintain the spirit of the project—keep it playful and creative.
-
Be responsive.
- Be open to feedback and respond to comments on your pull request promptly.
- Collaborate with the community to refine and improve your contribution.
Please note that all contributions are subject to review, and maintaining a positive and collaborative atmosphere is crucial.
- Nathanne Isip - Author
- Lady Selene - Illustrator
Copyright 2023 - Nathanne Isip
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.