Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514· AnthropicHugging Face LMArena Human Preference 140K

42 c project have list allow function per project (of course you can use your function),…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Googlegemma-3-27b-it’s answer.
  1. User

    42 c project have list allow function per project (of course you can use your function), libft is allow or not,.. i want write a robust linter to check it

  2. Claude Assistant

    A robust linter for 42 projects sounds like a useful tool! You'll need to handle the varying allowed functions across different projects and the libft situation.

    Here's a structure I'd recommend:

    Core Architecture:

    // Project configuration structure
    typedef struct s_project_config {
        char *name;
        char **allowed_functions;
        bool libft_allowed;
        char **forbidden_patterns;
        int max_functions_per_file;
        int max_lines_per_function;
    } t_project_config;
    

    Key Components:

    Function Detection: Parse C files to extract function calls using regex or a simple parser. You'll need to handle function calls in various contexts (direct calls, function pointers, etc.).

    Configuration System: Create JSON or YAML config files for each project:

    {
      "libft": {
        "allowed_functions": ["write", "malloc", "free"],
        "libft_allowed": false,
        "max_functions_per_file": 5
      },
      "get_next_line": {
        "allowed_functions": ["read", "malloc", "free"],
        "libft_allowed": true
      }
    }
    

    Libft Handling: When libft is allowed, you'll need to either parse the student's libft directory to see which functions they've implemented, or maintain a standard list of libft functions.

    Detection Strategies:

    • Parse #include statements to catch unauthorized headers
    • Use AST parsing or regex to find function calls
    • Check for system calls that might be disguised
    • Validate Makefile rules and linking

    Implementation Tips:

    • Start with a simple regex-based approach, then enhance with proper parsing
    • Handle edge cases like function pointers and macros
    • Consider using existing C parsers like libclang if you want robust AST analysis
    • Make it extensible so adding new projects is just configuration

    Would you like me to elaborate on any specific part, like the parsing logic or configuration management?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.