GithubHelp home page GithubHelp logo

c_std's People

Contributors

4794-sourse avatar aliokata avatar eltociear avatar kaisenamin avatar pyoneerc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

c_std's Issues

compile issue

Nice work! Added a standard compile chain to have a look but doesn't compile "as is". Feel free to borrow.

Dockerfile: builder.Dockerfile

ARG base_tag=bullseye
ARG base_img=mcr.microsoft.com/vscode/devcontainers/base:dev-${base_tag}

FROM --platform=linux/amd64 ${base_img} AS builder-install

RUN apt-get update --fix-missing && apt-get -y upgrade
RUN apt-get install -y --no-install-recommends \
    apt-utils \
    curl \
    cmake \
    build-essential \
    gcc \
    gdb \
    g++-multilib \
    locales \
    make \
    ruby \
    gcovr \
    wget \
    python3 \
    && rm -rf /var/lib/apt/lists/*

Makefile:

# project 
project_name=c_std

builder-build :
	docker build \
                    -f builder.Dockerfile 
                    -t ${project_name}-builder:latest .

builder-run :
	docker run \
		--rm \
		-it \
		--platform linux/amd64 \
		--workdir /builder/mnt \
		-v ${PWD}:/builder/mnt \
		${project_name}-builder:latest \
		/bin/bash
                #/bin/bash -c "python3 compile.py b"

Compile:

make builder-build
make builder-run

(container) python3 compile.py b

Output:

...truncated...
file_io/file_writer.c: In function ‘file_writer_lock’:
file_io/file_writer.c:494:15: warning: implicit declaration of function ‘fileno’ [-Wimplicit-function-declaration]
  494 |     if (fcntl(fileno(writer->file_writer), F_SETLKW, &fl) == -1) {
      |               ^~~~~~
file_io/file_writer.c: In function ‘file_writer_truncate’:
file_io/file_writer.c:580:9: warning: implicit declaration of function ‘ftruncate’; did you mean ‘strncat’? [-Wimplicit-function-declaration]
  580 |     if (ftruncate(fd, size) == -1) {
      |         ^~~~~~~~~
      |         strncat
Compilation failed.

compile issue

  1. Excess duplicate parameters
    image

  2. Not including necessary header file path
    image

JSON considers that if it is not a single value it should be ignored

//json.c:621
    if (state.current_token.type == JSON_TOKEN_OBJECT_START) {
        root = parse_object(&state);

    } 
    else if (state.current_token.type == JSON_TOKEN_ARRAY_START) {
        root = parse_array(&state);
    } 
    else {
        fmt_fprintf(stderr, "Error: Root element must be an object or array at position %zu.\n", state.position);
        free(state.input); 
        return NULL;
    }

But a json can be valid as a single and unique value

"value"
53

etc...

No Trie yet

I noticed there is no Trie (prefix tree) module yet. I am almost finished writing one then I'll initiate a PR. Apologize for any time lag in advance, I work on it when day job isn't occupying all my time.

Multiple issues with arrays and vectors "push_back,emplace_back" in multiple files

I may add all issues about vector_push_back,vector_emplace_back and related for reference to check

// json.c:789
        case JSON_ARRAY:
            for (size_t i = 0; i < vector_size(element->value.array_val); ++i) {
                JsonElement *item = json_deep_copy(*(JsonElement **)vector_at(element->value.array_val, i));
                if (!item) {
                    json_deallocate(copy);
                    return NULL;
                }
                vector_push_back(copy->value.array_val, &item);
            }
            break;

What is expected here for example if vector_push_back fails ? Should not we free all the copied data and return NULL ?
Because user may have a error message but nothing is recoverable from here...

[bug log] the fmt library

Platform Ubuntu22.04

Hi, when I test your code I find a good way to solve it without use the FMT_END_ARGS in fmt.c locate in fmt_print and fmt_println.

Recurrence

when i use the api , i don't want to use it with the define FMT_END_ARGS just like the following code.

int main() {
    const char* str = "Hello, World!";
    fmt_println(str);
    return 0;
}

the output is

Compilation successful. Output: ./build/main
Running the program...
*************************
Hello, World! �L�� �L�� @!�I�U  ��UH��AWAVAUATSH��8L�%�I 

How to Fix it

There is a high probability that garbled characters appear because you cannot use simple define va_arg() to show all parameter list in C code. It causes undefined behavior.

You should change the title & description

The description of this project is clickbaity and misleading.

This is NOT the C++ Standard Libraries, it's a try-implementation of the C++ std libs.

Vulnerability-fixes and Performance is not even close to the standard c++ implementation.

Please change the description to better address this, you can change to the similarities of "Basic C++ libraries for C", just don't put "THE STANDARD".

Feedback and nice things to implement

Do you mind considering using NULL pointer or -1 as return value for when there is an error instead of exit(-1) ? It isn't safe to use with exit(-1) because most of the time we don't want an application to crash because of a simple error even if it's memory related.

But also, is it possible to guard each call to fmt_fprintf with a "#ifdef LOGGING_ENABLE" or "#ifndef LOGGING_DISABLE" ? We don't want all the time printing to stderr libraries error in client applications

Dangerous issue with reserve and vector_emplace in vector.h

    if (vec->size == vec->capacitySize) {
        vector_reserve(vec, vec->capacitySize * 2); // Use the modified version
    }
    char *base = (char *)vec->items;
    memmove(base + (pos + 1) * vec->itemSize, 
            base + pos * vec->itemSize, 
            (vec->size - pos) * vec->itemSize);
    memcpy(base + pos * vec->itemSize, item, vec->itemSize);
    vec->size++;

What is the vector supposed to do when reserve fails this is actually a really dangerous matter as we may overwrite data. There shall be a way to inform the user of problems (other than just printing out a message)

Simply returning a boolean maybe ?

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.