tinycc | My fork of Fabrice Bellard 's Tiny C Compiler

 by   run4flat C Version: Current License: LGPL-2.1

kandi X-RAY | tinycc Summary

kandi X-RAY | tinycc Summary

tinycc is a C library. tinycc has no bugs, it has no vulnerabilities, it has a Weak Copyleft License and it has low support. You can download it from GitHub.

TinyCC (or tcc) is short for Tiny C Compiler. This a clone of the mob development repo at
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              tinycc has a low active ecosystem.
              It has 26 star(s) with 12 fork(s). There are 8 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 3 open issues and 5 have been closed. On average issues are closed in 173 days. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of tinycc is current.

            kandi-Quality Quality

              tinycc has 0 bugs and 1 code smells.

            kandi-Security Security

              tinycc has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              tinycc code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              tinycc is licensed under the LGPL-2.1 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              tinycc releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.
              It has 13 lines of code, 1 functions and 1 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tinycc
            Get all kandi verified functions for this library.

            tinycc Key Features

            No Key Features are available at this moment for tinycc.

            tinycc Examples and Code Snippets

            No Code Snippets are available at this moment for tinycc.

            Community Discussions

            QUESTION

            IS_BIG_ENDIAN macro works but not in #if
            Asked 2021-Jul-14 at 13:18

            This is puzzling me: If I comment out everything from the #if to the #endif the program compiles in C99 (TinyCC). With the conditional in it gives the error ')' expected (got "0") at the line before the #if clause

            ...

            ANSWER

            Answered 2021-Jul-14 at 11:46

            The preprocessor commonly does not know how to evaluate all C expressions. Its capabilities are quite limited.

            If you comment out if line with #if, the macro will not be evaluated. That's why you don't get an error.

            But if the macro is evaluated you make the preprocessor parse the expression. Apparently it cannot do this.

            Source https://stackoverflow.com/questions/68374929

            QUESTION

            Curious readonly symbols showing up as in initialized-data-section (D) in nm
            Asked 2021-Jan-31 at 15:23

            I've noticed that with gcc (but not clang), const (readonly) initialized data objects no longer show up as R data objects in nm and instead they become D (initialized section) objects.

            That would suggest the data object will be placed in writable memory, however, when the same object file is linked with either gcc or clang (but not tcc), then it seems to be placed in readonly memory anyway.

            clang doesn't seem to use these curious readonly-D symbols (instead the object remains R). Tinycc does make such objects into D symbols too, but those D symbols doesn't seem to have that curious property that causes linkers to put them in readonly memory.

            Can you explain what's going on here?

            The script below demonstrates the behavior with gcc, clang, and tinycc used in all combinations as compilers and linkers:

            ...

            ANSWER

            Answered 2021-Jan-31 at 15:23

            Most likely your gcc is configured with --enable-default-pie (gcc -v to check).

            In PIE, readonlyObject needs to be writable at program startup to allow dynamic relocation processing code to write the address of fn0 into its first field. To arrange for that, gcc places such objects into sections with .data.rel.ro prefix, and the linker collects such sections separately from other .data sections. The dynamic linker (or, in case of static PIEs, linked-in relocation processing code) can then mprotect that region after writing into it.

            Thus, with gcc (and implicit -fpie -pie) you have:

            • readonlyObject in .data.rel.ro
            • classified by nm as "global data"
            • writable at program startup for relocation
            • readonly when main is reached

            With clang or gcc -fno-pie you have:

            • readonlyObject in .rodata
            • classified by nm as "global constant"
            • readonly even on program startup

            Source https://stackoverflow.com/questions/65978465

            QUESTION

            Dynamically construct user-defined math function for efficient calling in C++?
            Asked 2020-Sep-16 at 07:16

            An example is something like Desmos (but as a desktop application). The function is given by the user as text, so it cannot be written at compile-time. Furthermore, the function may be reused thousands of times before it changes. However, a true example would be something where the function could change more frequently than desmos, and its values could be used more as well.

            I see four methods for writing this code:

            1. Parse the user-defined function with a grammar every single time the function is called. (Slow with many function calls)
            2. Construct the syntax tree of the math expression so that the nodes contain function pointers to the appropriate math operations, allowing the program to skip parsing the text every single time the function is called. This should be faster than #1 for many function calls, but it still involves function pointers and a tree, which adds indirection and isn't as fast as if the functions were pre-compiled (and optimized).
            3. Use something like The Tiny C Compiler as the backend for dynamic code generation with libtcc to quickly compile the user's function after translating it into C code, and then use it in the main program. Since this compiler can compile something like 10,000 very simple programs on my machine per second, there should be next to no delay with parsing new functions. Furthermore, this compiler generates machine code for the function, so there are no pointers or trees involved, and optimization is done by TinyCC. This method is more daunting for an intermediate programmer like me.
            4. Write my own tiny compiler (not of C, but tailored specifically to my problem) to generate machine code almost instantly. This is probably 20x more work than #3, and doesn't do much in the way of future improvements (adding a summation operation generator would require me to write more assembly code for that).

            Is there any easier, yet equally or more efficient method than #3, while staying in the realm of C++? I'm not experienced enough with lambdas and templates and the standard library to tell for sure if there isn't some abstract way to write this code easily and efficiently.

            Even a method that is faster than #2 but slower than #3, and requires no dynamic code generation would be an improvement.

            This is more of an intellectual curiosity than a real-world problem, which is why I am concerned so much with performance, and is why I wouldn't use someone else's math parsing library. It's also why I wouldn't consider using javascript or python interpreter which can interpret this kind of thing on-the-fly.

            ...

            ANSWER

            Answered 2020-Sep-16 at 03:06

            I think something along the lines of your option 2 would be good. Except maybe to be a little easier would be to have an Expr class with a float Expr::eval(std::unordered_map vars) method. Then implement subclasses like Var with a name, Add with left and right, Sub, Mult, Div, etc all the functions you want. When evaluating you just pass in the map with like {{"x",3},{"y",4}} or whatever and each Expr object would pass that down to any subexpressions and then do it's operation.

            I would think this would be reasonably fast. How complicated of expressions do you think your user's would be putting in? Most expressions probably won't require more than 10-20 function calls.

            It can also get a lot faster

            If you're trying to make something that graphs functions (or similar) you could speed this up considerably if you made your operations able to work with vectors of values rather than single scalar values.

            Assuming you wanted to graph something like x^3 - 6x^2 + 11x - 6 with 10,000 points, if you had your Expr objects only working on single values at a time, yeah this would be like ~10-15 function calls * 10,000 points = a lot jumping around! However, if your Expr objects could take arrays of values, like calling eval with {{"x",[1,2,3...10000]}} then this would only be ~10-15 function calls, total, into optimized C++. This could easily scale up to a larger number of points and still be very fast.

            Source https://stackoverflow.com/questions/63894460

            QUESTION

            How set CMAKE_STATIC_LINKER_FLAGS immediately after the executable file? [tcc -ar]
            Asked 2020-Jun-12 at 08:07

            How set CMAKE_STATIC_LINKER_FLAGS in CMakeLists.txt immediately after the executable file?

            for example: I need:

            tcc.exe-arqc staticRun.lib CMakeFiles/staticRun.dir/utils/system.c.obj

            but cmake after this settings:

            set (CMAKE_AR C:/run/code/toolchains/c++/MinGW-tcc/bin/tcc.exe CACHE FILEPATH "" FORCE)

            set (CMAKE_STATIC_LINKER_FLAGS -ar CACHE STRING "" FORCE)

            add -ar key like this:

            tcc.exe qc staticRun.lib CMakeFiles/staticRun.dir/utils/system.c.obj-ar

            so, building the static library failed.

            P.S.

            tcc.exe -ar - mean

            Tools: create library : tcc -ar [rcsv] lib.a files

            ...

            ANSWER

            Answered 2020-Jun-12 at 08:07

            The simplest is just to change the line that is used to run the static library with your custom semantics:

            Source https://stackoverflow.com/questions/62339192

            QUESTION

            win32 without mouse, how to assign keyboard shortcuts to buttons
            Asked 2020-Apr-29 at 12:58

            I wrote a simple win32 GUI application with buttons and other controls, in pure C, no MFC. I want to make it more accessible for those who can not use mouse.

            1. First, my example code does not respond to Tab key to move focus from one button to another. I can press UI button using mouse, than it becomes focused and i can activate button using Space-bar, but i can't move focus to other buttons using Tab or Shift+Tab. How can i fix this?

            2. I want to assign keyboard cues (little underscores) to buttons, so user can use keyboard shortcuts to activate buttons.

            I have google it around, but answers are hard googleable, so i need someone to point me to some documentation. A little piece of code would be very helpful.

            Here is the code i have. I compile and run it on Linux using WINE + TinyCC

            ...

            ANSWER

            Answered 2020-Apr-29 at 12:58

            It was simple. In main message processing loop, i call IsDialogMessage() with proper HWND. Then, if this function returns zero, i call normal TranslateMessage and DispatchMessage functions. Here is code:

            Source https://stackoverflow.com/questions/61478202

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install tinycc

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/run4flat/tinycc.git

          • CLI

            gh repo clone run4flat/tinycc

          • sshUrl

            git@github.com:run4flat/tinycc.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link