C-Toy is an interactive C(99) coding environment based on TCC.

Overview

C-Toy

C-Toy is an interactive C(99) coding environment based on TCC.

Small, simple, no bullshit. Write cross-platform C code and see the result immediately. No installation or compiler required, download (<4mb), unzip, run CToy and play. Ready for Windows, MacOSX and Linux. Ideal for prototyping, learning, teaching...

Features

  • CToy: program update on file save (use any text editor)
  • CToy_player: to publish your project (dynamic update disabled)
  • API for window managment, inputs, persistent memory...
  • Image processing with MaratisTCL
  • OpenGLES-2
  • OpenAL
  • Portable pen-tablet support (Wacom, etc)
  • Use C-symbols from native dynamic libraries (*.dll etc) : just copy libraries in your_ctoy_path/lib/
  • Pre-built Dear-Imgui suport (https://github.com/ocornut/imgui)
  • Can also compile your project with other compilers (CMake script for gcc, vs, mingw)
  • Emscripten compatible

Download

- CToy 1.06 Win64
- CToy 1.05 MacOSX
- CToy 1.05 Linux64
- [all versions]

Requirement For Linux: OpenAL

Getting started

  • Launch CToy
  • Open src/main.c using your favorite text editor
  • Start coding (samples included)
  • Save your file(s) and see the result in realtime

Usage

C-Toy expects a main file in src/main.c.
But instead of the standad C "main" function, the entry points are "ctoy_begin", "ctoy_main_loop" and "ctoy_end".

The compulsory "Hello, World!" program is then (in src/main.c):

#include <ctoy.h> // ctoy API (including frequently used ANSI C libs)

void ctoy_begin() // called at the beginning of the program
{
   printf("Hello, World!\n");
}

void ctoy_main_loop() // called at every update of the main loop
{}

void ctoy_end() // called at the end of the program
{}

Every time you modify src/main.c or any other file connected to it (directly or recursively included), C-Toy will recompile and restart the program dynamically.

One other difference with standard C is the use of persistent memory to maintain a bloc of memory intact between recompiles. For example:

#include <ctoy.h>

void *persistent_memory = NULL;

void ctoy_begin()
{
   if (ctoy_t() == 0) {
      persistent_memory = calloc(256, 1); // allocate 256 bytes with zero value
      ctoy_register_memory(persistent_memory); // register persistent memory
   }
   else {
      persistent_memory = ctoy_retrieve_memory(); // retrieve persistent memory
   }
}

void ctoy_main_loop()
{
   int *persistent_counter = (int *)persistent_memory; // access a piece of persistent memory
   (*persistent_counter)++; // do something with the data
   printf("persistent_counter = %d\n", (*persistent_counter)); // print the content
}

void ctoy_end()
{}

(You can store any data that was manually allocated with malloc, it can be an array or a global pointer. Just avoid storing function pointers, as functions addresses may change after recompiles, or update them after calling ctoy_retrieve_memory)

Documentation

C-Toy API: https://github.com/anael-seghezzi/CToy/blob/master/ressources/include/ctoy.h
MaratisTCL: https://github.com/anael-seghezzi/Maratis-Tiny-C-library
OpenGLES2: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/
OpenAL: https://www.openal.org/documentation/OpenAL_Programmers_Guide.pdf

Tutorials and examples

Wiki: https://github.com/anael-seghezzi/CToy/wiki

License

CToy is licensed under the zlib/libpng License.

Building CToy from sources (CMake)

Unix:

mkdir Build
cd Build
cmake -G "Unix Makefiles" ../ -DCMAKE_INSTALL_PREFIX=../bin -DCMAKE_BUILD_TYPE=Release
make
make install

Windows:

mkdir Build
cd Build
cmake -G "Visual Studio 11 Win64" ../ -DCMAKE_INSTALL_PREFIX=../bin

(libtcc.dll and libtcc.dylib where pre-built from a fork of tcc: libtcc-fork)

Comments
  • CToy crashes with SIGSEGV from libpthead.so, Arch Linux

    CToy crashes with SIGSEGV from libpthead.so, Arch Linux

    This wasn't an isssue on my machine with Ubuntu, but my laptop with Arch Linux. It's only relevant for the CToy executable. CToy_player does work, which makes sense because it doesn't compile with the thread stuff. What is the idea behind these two executables, CToy and CToy_player?

    I upgraded my entire system, and I still get the error, meaning that this fails with libpthread version 2.25 and 2.26.

    Thread 1 "CToy" received signal SIGSEGV, Segmentation fault. 0x00007ffff768d29e in pthread_join () from /usr/lib/libpthread.so.0 (gdb) bt #0 0x00007ffff768d29e in pthread_join () from /usr/lib/libpthread.so.0 #1 0x000000000047b7f1 in thrd_join () #2 0x0000000000464cbf in ctoy.src_thread_restart () #3 0x000000000043c579 in main ()

    opened by Smilex 10
  • Compiling on Linux, GLFW Question

    Compiling on Linux, GLFW Question

    Hey,

    I've been working on getting this to work on my Linux machine and I had linker issues with the GLFW you had bundled with it. I replaced it with https://github.com/glfw/glfw, and I got past those issues.

    Your GLFW directory has less stuff than the original. Is it because you got it from a fork, and if so could you give me a link? Or is it something you cleaned up yourself, in which case could you tell me what stuff I should cut out?

    UPDATE: CToy is now compiling & running on my Linux machine

    opened by Smilex 4
  • reserved identifier violation

    reserved identifier violation

    I would like to point out that identifiers like "_CTOY_H_" and "_M_DIST_T" do eventually not fit to the expected naming convention of the C language standard. Would you like to adjust your selection for unique names?

    opened by elfring 4
  • F*** you!

    F*** you!

    Why is this only available on 64-bit OS? I don't have any 64-bit PC at hand at the moment, so a port to 32-bit will make me happy. I have had enough with two other free fantasy consoles being only on 64-bit and not having a 32-bit release.

    opened by StinkerB06 2
  • Help with CToy

    Help with CToy

    Hey,

    I'm uncertain if the Github issue tracker should be used like this, but it does seem the most convenient for me.

    I'm writing some code with CToy that compiles C files, which it then runs. Similar to one of your samples. I'm getting the following errors about repetition, and I'm wondering if you recognise which part I'm missing?

    `In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:845: error: 'stbi_failure_reason' defined twice... may be -fcommon is needed?

    In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:876: error: 'stbi_image_free' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:944: error: 'stbi_load' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:968: error: 'stbi_load_from_memory' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:975: error: 'stbi_load_from_callbacks' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:996: error: 'stbi_loadf_from_memory' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1003: error: 'stbi_loadf_from_callbacks' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1011: error: 'stbi_loadf' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1035: error: 'stbi_is_hdr_from_memory' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1049: error: 'stbi_is_hdr' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1072: error: 'stbi_is_hdr_from_callbacks' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1086: error: 'stbi_ldr_to_hdr_gamma' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1087: error: 'stbi_ldr_to_hdr_scale' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1090: error: 'stbi_hdr_to_ldr_gamma' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:1091: error: 'stbi_hdr_to_ldr_scale' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3708: error: 'stbi_zlib_decode_malloc_guesssize' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3724: error: 'stbi_zlib_decode_malloc' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3729: error: 'stbi_zlib_decode_malloc_guesssize_headerflag' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3745: error: 'stbi_zlib_decode_buffer' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3756: error: 'stbi_zlib_decode_noheader_malloc' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:3772: error: 'stbi_zlib_decode_noheader_buffer' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:4144: error: 'stbi_set_unpremultiply_on_load' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:4149: error: 'stbi_convert_iphone_png_to_rgb' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:6155: error: 'stbi_info' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:6177: error: 'stbi_info_from_memory' defined twice... may be -fcommon is needed? In file included from /tmp/web_native/img_util.c:4: /tmp/web_native/stb_image.h:6184: error: 'stbi_info_from_callbacks' defined twice... may be -fcommon is needed? /tmp/web_native/img_util.c:7: error: 'm_image_load' defined twice... may be -fcommon is needed? /tmp/web_native/img_util.c:16: warning: implicit declaration of function 'm_image_create' /tmp/web_native/img_util.c:16: error: 'M_UBYTE' undeclared `

    opened by Smilex 2
  • Complete quoting for parameters of some CMake commands

    Complete quoting for parameters of some CMake commands

    Some parameters (like "${MTCL_SOURCE_DIR}/3rdparty/glfw/include") are passed to CMake commands in your build scripts without enclosing them by quotation marks. I see that these places will result in build difficulties if the contents of the used variables will contain special characters like semicolons.

    I would recommend to apply advices from a wiki article.

    opened by elfring 2
  • Missing VCOMP140.dll and VCRuntime140.dll

    Missing VCOMP140.dll and VCRuntime140.dll

    On a freshly installed Windows 10, downloaded CToy-1.05-WIN-x86_64.zip When I launch CToy.exe or CToy_player.exe it reports missing dlls from Microsoft Visual C++ 2015 Redistributable

    Downloading and installing Redist solves the problem, so it's not a big issue. https://www.microsoft.com/en-us/download/confirmation.aspx?id=52685

    opened by ivan-cx 1
  • Consider replacing OpenAL by mini_al

    Consider replacing OpenAL by mini_al

    My experience: after more than 4 years using OpenAL for raylib, just switched to mini_al library.

    It's small, single-file header-only, multiplatform and removed the need of distributing OpenAL32.dll with your programs. I think it can make CToy a more self-contained product.

    question 
    opened by raysan5 1
  • dyld: Library not loaded: @rpath/libtcc.dylib crash

    dyld: Library not loaded: @rpath/libtcc.dylib crash

    When i try to run ctoy from mac os High Sierra (after compiling from source code) i got this error. dyld: Library not loaded: @rpath/libtcc.dylib Referenced from: /Users/Renato/Downloads/CToy/Build/src/./CToy_player Reason: image not found Abort trap: 6

    Any ideas why ?

    opened by renatorabelo 1
  • Can I opt to remove GLES window?

    Can I opt to remove GLES window?

    I want to use CToy for learning algorithms, but it is very annoying to see a black screen that I never needs...

    Also, I wish there could be Makefile support so we have can a live-reloading infrastructure in basically anywhere.

    opened by stevefan1999-personal 1
  • Issue with my Linux port

    Issue with my Linux port

    It relies on a system installation of your fork of tcc. I get this error now that I've removed it - "tcc: error: file '/usr/local/lib/tcc/x86-64/libtcc1.a' not found"

    I guess this is some RPATH thing. I did readelf -d, and the RPATH entry looks like this: 0x000000000000000f (RPATH) Library rpath: [$ORIGIN/]

    libtcc1.a is correctly installed alongside the CToy executable.

    I will fix this

    opened by Smilex 1
  • [Feature Request] Official RaspberryPi Package

    [Feature Request] Official RaspberryPi Package

    A lot of people are interested in running fantasy consoles on RPi, as an easy way of creating games that will run well on limited hardware. Something similar, based on C, could be popular.

    enhancement help wanted 
    opened by carlsmith 9
Owner
Anaël Seghezzi
Anaël Seghezzi
A vim plugin for libclang-based highlighting of C, C++, ObjC

color_coded: semantic highlighting with vim color_coded is a vim plugin that provides realtime (fast), tagless code highlighting for C++, C, and Objec

Jeaye Wilkerson 864 Jan 3, 2023
A client/server indexer for c/c++/objc[++] with integration for Emacs based on clang.

rtags rtags-xref ac-rtags company-rtags flycheck-rtags helm-rtags ivy-rtags Introduction RTags is a client/server application that indexes C/C++ code

Anders Bakken 1.8k Jan 2, 2023
Interactive-hex-meshing - Source code for "Interactive All-Hex Meshing via Cuboid Decomposition [SIGGRAPH Asia 2021]".

Interactive All-Hex Meshing via Cuboid Decomposition Video demonstration This repository contains an interactive software to the PolyCube-based hex-me

Lingxiao Li 131 Dec 5, 2022
This repo contains solutions to coding questions available online on coding platforms like - Codeforces, Codechef, URI Online Judge, and Hackerrank.

CPP_Soln This repo contains solutions to coding questions available online on coding platforms like - Codeforces, Codechef, URI Online Judge , LeetCod

Rijul Jain 4 Nov 3, 2022
This repository contains toy ImPlot applications that demonstrate some of the library's functionality

ImPlot Demos This repository contains toy ImPlot applications that demonstrate some of the library's functionality.

Evan Pezent 83 Dec 28, 2022
A toy renderer written in C using Vulkan to perform real-time ray tracing research.

This is a toy renderer written in C using Vulkan. It is intentionally minimalist. It has been developed and used for the papers "BRDF Importance Sampl

Christoph Peters 290 Dec 19, 2022
A minimal, toy programming language implemented in C++ and STL.

od Programming Language Mod (or ModLang) is a minimal, toy programming language implemented in C++ and STL (Standard Template Library) with no other e

Pranav Shridhar 27 Dec 4, 2022
Toy LLVM obfuscator pass

ToyObfuscator Some simple obfuscator ;) (base on llvm-10) Compile Build out-tree pass git clone https://github.com/veritas501/ToyObfuscator.git cd Toy

veritas501 51 Nov 6, 2022
🎀 toy gemini client in ansi c (c89)

?? viv a toy gemini client written in ansi c (c89). nowhere near finished, but it works! (mostly). what works ? everything except the custom ui. limit

GemRest 3 Apr 17, 2022
A small toy Directx 11 and Directx 12 3D Engine

Charlie A Directx 11 and Directx 12 3D Engine. Building Windows Requirements git Visual Studio 2019 (windows) with the following workflows: Python dev

Jonathan Hoffstadt 10 Nov 23, 2022
Toy 8 bit CPU with a real assembler

neko8 neko8 is a 8 bit CPU emulator designed to be easy to learn written in C. It uses its own simple architecture and can be programmed in its own fo

rem 4 Jan 4, 2022
TotoroEngine is a toy 3D game engine using DirectX 12.

TotoroEngine TotoroEngine is a toy 3D game engine using DirectX 12. Prerequisites Only support Windows(Only test on Windows 10). If you have not insta

null 36 Dec 18, 2022
A Simple Toy Programming Language

Tovie Lang Small toy programming language. Docs : https://github.com/Jaysmito101/tovie/wiki Examples : 1. Hello World proc_0 "Hello" 32 "World!"

Jaysmito Mukherjee 23 Dec 20, 2022
A toy implementation of socket programming for Lean 4.

Lean4-Socket A toy implementation of socket programming for Lean 4. Installation Lake import Lake open System Lake DSL package foo where dependenci

王虛白 18 Jul 21, 2022
Toy path tracer for my own learning purposes (CPU/GPU, C++/C#, Win/Mac/Wasm, DX11/Metal, also Unity)

Toy Path Tracer Toy path tracer for my own learning purposes, using various approaches/techs. Somewhat based on Peter Shirley's Ray Tracing in One Wee

Aras Pranckevičius 931 Dec 29, 2022
nn - a toy operating system, designed for fun

nn is a toy operating system, designed for fun (and from a position of general naïveté). i'm not sure how far it'll go, but one thing's for sure: it'll probably implement nearly nothing.

Lux L. 2 Jan 28, 2022
Eve programming Language. Toy project.

Eve Programming Language How to use Eve Install & Run $ sudo make install $ eve <filename>.eve Version check $ eve -v Clean $ sudo make clean Hell

tsharp0x11 66 Jun 28, 2022
A ROS based Open Source Simulation Environment for Robotics Beginners

A ROS based Open Source Simulation Environment for Robotics Beginners

Sulegeyixiu 131 Jan 5, 2023
C++-based high-performance parallel environment execution engine for general RL environments.

EnvPool is a highly parallel reinforcement learning environment execution engine which significantly outperforms existing environment executors. With

Sea AI Lab 709 Dec 30, 2022
A library for interactive command line interfaces in modern C++

cli A cross-platform header only C++14 library for interactive command line interfaces (Cisco style) Features Header only Cross-platform (linux and wi

Daniele Pallastrelli 888 Dec 31, 2022