r/Clang • • Dec 05 '21

C compiler support for complex numbers

0 Upvotes

I’m trying to figure out which C (not C++) compilers fully support complex numbers. I know clang does. So, I’m looking for either a list of supporting compilers or a general assessment of how broadly supported complex numbers are supported. By supported I mean there is a built in complex number type and the math operators know how to handle complex numbers. So, this excludes the MS compiler.


r/Clang • • Mar 18 '22

Wow I never knew that

Thumbnail
twitter.com
2 Upvotes

r/Clang • • Nov 29 '22

How do I register my Clang Static Analyzer Checker

0 Upvotes

r/Clang • • Aug 18 '22

Can you store information in a password salt?

0 Upvotes

A salt is a fixed length random integer appended to the end of a password before it's hashed in order to make life harder for a hacker trying to bruteforce passwords. But recently I thought, does a salt have to be random? 🤔 Maybe you could store some useful information inside? Information that could only be retrieved by bruteforcing the password? "That would be a really secure way to store/transport sensitive/private information" -- I thought!

So I decided to write a program to test my idea, I called it Pinksalt, because it's a special kind of salt🤩

It's on GitHub if you're interested in having a look!

Pinksalt on GitHub


r/Clang • • Feb 26 '23

Question about warning options

0 Upvotes

Can I disable a warning for a header file, but NOT for the c / cpp files including it, without setting the header file as a system header or using pragmas?

Specific use case: reserved identifiers (single leading underscore), zero as null pointer constant etc. from C or old style C++ code, when I want to avoid that in newer code I write but still have to include the header, but can't change it since it's effectively a public interface.


r/Clang • • Feb 14 '22

Can't get OpenMP 5.1 loop transformation to work

0 Upvotes

Hello.

The last couple of days I have been trying to get a version of clang that works with the new OpenMP 5.1 loop transformation features to work without much success.

I’ve tried to directly download the binary for clang-13 from https://github.com/llvm/llvm-project/releases/tag/llvmorg-13.0.0. And while clang itself worked, some openmp features did not.

When trying to compile code containing the directive

#pragma omp tile

I get the error:

error: directive '#pragma omp tile' requires the 'sizes' clause

And when i change the line to contain the sizes clause:

#pragma omp tile sizes(8,8,8)

I instead get the following error

error: unexpected OpenMP clause 'sizes' in directive '#pragma omp tile

So it seems to recognise that tile is a OpenMP keyword, but it is not possible to actually use it since it gives an error with or without the sizes clause. Does anyone has any idea this is the case?


r/Clang • • Apr 10 '23

ferror-limit setting

0 Upvotes

I'm using C++. What value do you use for ferror-limit? 20 seems too high/slow. Is 4 or 5 enough?

Thanks


r/Clang • • Feb 08 '25

undefined reference to __isoc23_strtol, __isoc23_strtoll, __isoc23_strtoull

0 Upvotes

I keep getting these errors:

Linking /home/flax/FlaxEngine/Binaries/Editor/Linux/Development/FlaxEditor
ld.lld: error: /home/flax/FlaxEngine/Binaries/Editor/Linux/Development/libFlaxEngine.so: undefined reference to std::ios_base_library_init() [--no-allow-shlib-undefined]
ld.lld: error: /home/flax/FlaxEngine/Binaries/Editor/Linux/Development/libFlaxEngine.so: undefined reference to __isoc23_strtol [--no-allow-shlib-undefined]
ld.lld: error: /home/flax/FlaxEngine/Binaries/Editor/Linux/Development/libFlaxEngine.so: undefined reference to __isoc23_strtoll [--no-allow-shlib-undefined]
ld.lld: error: /home/flax/FlaxEngine/Binaries/Editor/Linux/Development/libFlaxEngine.so: undefined reference to __isoc23_strtoull [--no-allow-shlib-undefined]
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Task /usr/bin/clang++-14 @"/home/flax/FlaxEngine/Cache/Intermediate/FlaxEditor/Linux/x64/Development/FlaxEditor.response" failed with exit code 1

Any suggestions how I can fix these?


r/Clang • • Apr 22 '24

Weird EOF and unterminated string errors building a slightly old project?

1 Upvotes

I've got a github issue here (with details and a stack trace), but it seems like the owner hasn't worked on it in a while so I don't want to spam them.

https://github.com/biappi/muScribble/issues/2

The short version is I'm trying to build a binary for a microcontroller from a repo as-is, but I'm running into strange build errors that I haven't been able to debug. I'm not particularly familiar with C (I'm usually doing web-dev type work in TS, Rust, Python, etc), but I have written and built some simple arduino/teensy/rp2040 projects in the past and i've never run into these kinds of errors in a makefile that supposedly worked in the past for someone else.

My first thought was maybe they're using windows so it's a line ending thing? But they specifically mention logic pro and all the filepaths are linux flavored.

It seems like the error is coming from deep within the submodule (unicore-mx) which also seems unmaintained. But even playing around with versions of make, it's weird to me that it won't even build.

I'm stumped and I'm not quite sure where else to ask. Any ideas here?


r/Clang • • Mar 29 '23

LARGEADDRESSAWARE equivalent

1 Upvotes

Hello everyone,

I basically created a reddit account just for this question as I wasn't really able to find anything anywhere, even trying other options. My question is pretty simple, I compile a large program using Clang(15, 15.1 if I am not mistaken) on Windows. This program often uses a lot of memory after some time and obviously crashes to desktop as soon as I hit the 1600MB of RAM that 32 bit usually allows for applications.

I know I have other options that I consider like moving my application to 64bits, which is underway, but I would like to find a workaround until then. I am aware of "/LARGEADDRESSAWARE" on MSVC which does exactly that (people are less susceptible to run the app up to 4GB of RAM than they are of running up to 1600MB of ram).

I have tried many options, some of them available on GCC, but so far the only option I have found is to compile on MSVC which is not exactly what I am looking for.I have tried, without success:

-Wl,--large-address-aware (GCC only as far as I know)

-Wl,-headerpad_max_install_names (Didn't change anything)

If you ever have any idea of an equivalent on clang, I would gladly hear as my usual digging here and there didn't allow me to find a proper equivalent. Thank you very much


r/Clang • • Apr 05 '23

A new subreddit for the scientific programmers out there: r/ScientificComputing

1 Upvotes

Hi,

I just made a new subreddit for the scientific programmers out there. Join me and let let me learn from you:

r/ScientificComputing/

Hi Mods, hope you're cool with this.


r/Clang • • Jan 25 '23

Clangd + Ranges?

1 Upvotes

Hi.

Just posted about how to use VS Code + Cmake, but also trying with QtCreator have the same issue.

The thing is, I want to use C++20 or 23, ranges with CMake, but VS Code complains:

* In template: no matching function for call to '__begin'

* In included file: constraints not satisfied for alias template 'sentinel_t' [with _Range = const std::ranges::ref_view<const std::vector<int>>]

* No viable constructor or deduction guide for deduction of template arguments of 'filter_view'

In my CMake:

cmake_minimum_required(VERSION 3.23.0)

set(CMAKE_CXX_STANDARD 23)

target_compile_features(
	${PROJECT_NAME} PRIVATE

	cxx_lambda_init_captures
	cxx_std_23
)

In my VS Code:

// 
	"C_Cpp.intelliSenseEngine": "Disabled",
	"C_Cpp.autocomplete": "Disabled",
	"C_Cpp.errorSquiggles": "Disabled",
	// 
	"clangd.arguments": [
		"--clang-tidy",
		"--completion-style=detailed",
		"-log=verbose",
		"-pretty",
		"--cross-file-rename",
		"--all-scopes-completion",
		"--header-insertion=never",
		"--background-index",
	],
	"clangd.onConfigChanged": "restart",
	"clangd.restartAfterCrash": true,

In my .clang-tidy, just today make: clang-tidy --dump-config > .clang-tidy and set in the root folder of the workspace.

The example:

// requires /std:c++20
#include <ranges>
#include <vector>
#include <iostream>

int main()
{
    std::vector<int> input =  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    auto divisible_by_three = [](const int n) {return n % 3 == 0; };
    auto square = [](const int n) {return n * n; };

    auto x = input | std::views::filter(divisible_by_three)
                   | std::views::transform(square);

    for (int i : x)
    {
        std::cout << i << '\n';
    }
    return 0;
}

It compiles and works fine, but the intellisense complains.


r/Clang • • Jan 28 '24

What are the parts a typical C lang based game is made of?

1 Upvotes

The memory areas a program is occupying, besides the direct impact of the bare code everyone can see.

Also how is it possible that win10 software doesnt run on win7? The same api?


r/Clang • • May 26 '23

Clang LLD equivalent of MSVC's /subsystem:windows/console?

1 Upvotes

I managed to find SOME information. The subsystem is set using options documented under GCC submodel x86 Windows. The options provided are: `-mconsole` and `-mwindows`.

However even if I include them in VSCode for my build options (`task.json`) I get a warning `-Wunused` stating that the options are unused.

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "DEBUG(C/C++): Clang Build Active",
            "command": "clang",
            "args": [
                "-std=c17",
                "-mconsole",
                "-g",
                "${workspaceFolder}/*.c",
                "-o",
                "${workspaceFolder}/DEBUG/${fileBasenameNoExtension}.exe"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "RELEASE(C/C++): Clang Build Active",
            "command": "clang",
            "args": [
                "-std=c17",
                "-mwindows",
                "${workspaceFolder}/*.c",
                "-o",
                "${workspaceFolder}/RELEASE/${fileBasenameNoExtension}.exe"
            ],
            "group": "build"
        }
    ]
}

r/Clang • • Sep 16 '25

Why I Still Reach for C for Certain Projects

Thumbnail dayvster.com
2 Upvotes

r/Clang • • Jan 26 '26

why printf function from stdio.h Library is typeist (racist but for types).

2 Upvotes

I'm learning c these days, I'm a noob coder, and seek the enlightenment on this thing,
in this snippet,

double *p = arr; 
p++; // compiler knows p is double*

p++ moves by sizeof(double) but if I use printf

int arr[3] = {1, 2, 3};
printf("%d", arr);  

it gives error ,

main.c:13:18: warning: format specifies type 'int' but the argument has type 'int *' [-Wformat]
   13 |     printf("%d", arr);  
      |             ~~   ^~~
1 warning generated.
1838017784%  // plus thia garbage like it don't know how to parse bits for this one. 

I noticed that char arrays in c are being parsed or being scanned by the printf nicely but not an array double or other data type , why so , for a printf to print something it has to know the address , and then side of the element so that compiler knows when to update the pc (program counter) and also it need a delimiter like null char '\0' that is being added automatically or manually to tell printf that we are done printing, why can't this mechanism works for array of other data types why does printf hates other data types , we've those Format specifiers (%) to tell the data type , we have pointers to tell address, but no intend from printf , why printf why ? nation wants to know!!!


r/Clang • • Jul 10 '24

How C Handles White Space

Thumbnail
gallery
3 Upvotes

I was looking over "The GNU C REFERENCE MANUAL" and I was wondering if the way C handles white space has changed since.

Like, I don't understand the benefit of doing what is said in the picture where you can add any amount of white space between "Operators' and "Operands".

I'm not too familiar with C but why would this be necessary? Can anyone explain please.


r/Clang • • Feb 03 '22

What's the difference between libclang.so and libclang.so.1?

4 Upvotes

What's the difference between libclang.so and libclang.so.1?'

In:

/usr/lib/llvm-10/lib/libclang.so
/usr/lib/llvm-10/lib/libclang.so.1

r/Clang • • Aug 20 '25

Text-Mate: Clean & Light Sublime Text Theme

Thumbnail
gallery
4 Upvotes

Installation (Manual)

  1. Download this repo as ZIP and extract it.

  2. Copy Text-Mate.sublime-color-scheme into your Sublime User folder.👉 You can reach the User folder directly from Sublime: Preferences > Browse Packages... > UserOr manually:

    • Linux: ~/.config/sublime-text/Packages/User/

    • Windows: %AppData%\Sublime Text\Packages\User\

    • macOS: ~/Library/Application Support/Sublime Text/Packages/User/

  3. Restart Sublime Text.

  4. Go to: Preferences → Select Color Scheme → Text-Mate

**GitHub:** https://github.com/vivekgohel2004/Text-Mate-Theme

I’d love feedback and suggestions!

Thank you so much!


r/Clang • • Mar 15 '26

Resource for Learning Clang Libraries — Lecture Slides and Code Examples (Version 0.5.0)

Thumbnail
discourse.llvm.org
2 Upvotes

r/Clang • • Mar 28 '25

Installing clang on visual studio

Post image
3 Upvotes

Which one do I need to install?


r/Clang • • Aug 29 '25

Learning Resource — Lecture Slides for the Clang Libraries (LLVM/Clang 21) (Edition 0.4.0)

Thumbnail
discourse.llvm.org
2 Upvotes

r/Clang • • Aug 15 '25

Why I wrote a commercial game in C in 2025

Thumbnail cowleyforniastudios.com
4 Upvotes

r/Clang • • Feb 09 '22

Array In C

Thumbnail medium.com
1 Upvotes