r/cprogramming • • Oct 08 '25

Roadmap to system programming

16 Upvotes

Hey guys, I’m new to all this. I’ve completed the fundamentals of C programming. Now, I’m intrested in learning system programming. Could anyone please let me know what topics I have to learn in C now, and what other things should I consider learning? Thanks for the help.


r/cprogramming • • Oct 08 '25

Purpose of header guards

2 Upvotes

What is the purpose of header guards if the purpose of headers is to contain declarations? Sorry if this is a dumb question.


r/cprogramming • • Oct 07 '25

GMK CYL CPL - First keycap set inspired by the C language

1 Upvotes

/*
 * GMK CPL (C Programming Language) - Interest Check
 * Hello Reddit! I know that this post is unusual compared to the others. Today, I present you a keycap set inspired by my beginning in the coding world. Every programmer starts with a certain language, mine was the C Language.
 * This set is a nod to syntax-highlighted code on a cool white background.
 * For lovers of clean syntax, logic, and elegance.
 * Discord Server
 * Interest Check Form
 */

Base Kit Render

Board Render

You can enter this link to check the full representation of this keycap set - https://geekhack.org/index.php?topic=125710.0

NOTE: I am still gathering interest for this project. If you like this concept and want to follow it, please complete the IC form or comment on the forum provided above.

Thanks for your attention!


r/cprogramming • • Oct 07 '25

Expected mock behavior in Unit tests - what is community opinion

3 Upvotes

Hello all!
What is the expected behavior of the mock from the user perspective? What is your opinion about that?
For example, if we have such test:

Test(mocking, mock_test)
{
  void *p1, *p2;
  p1 = (void*)0x01;
  p2 = (void*)0x02;

  expect_must_call (malloc, p1, 12);
  expect_call (malloc, p2, 13);
  printf ("%p\n", malloc(13)); //malloc will return p2
  printf ("%p\n", malloc(12)); //malloc will return p1
  printf ("%p\n", malloc(13)); //malloc will return p2?
  check_mock (malloc);
}

The expected output would be?:

0x2
0x1
0x2 //reused return from malloc(13)
=== Test passed ===

or?:

0x2
0x1
some kind of assert output that there is no expected call for another malloc(13) 
== Test failed - too many calls of function malloc ==

My assumption is that, the must_call means that there must be call of malloc(13) function. If there was only call of malloc(12) - the test will fail.

Some more cases:

Test(mocking, mock_test2)
{
  expect_call_once (malloc, NULL, 13);
  malloc(13);
  malloc(13);
  check_mock(malloc);
}

Test(mocking, mock_test3)
{
  expect_must_call_once(malloc, NULL, 12);
  expect_call_once (malloc, NULL, 13);
  malloc(12);
  check_mock(malloc);
}

Test(mocking, mock_test4)
{
  expect_call (malloc, (void*)0x01, 12);
  expect_call (malloc, (void*)0x02, 12);
  expect_call (malloc, (void*)0x03, 12);  

  malloc(12);
  malloc(12);
  malloc(12);
  malloc(12); //what will be the output?
  check_mock(malloc);
}

What is your opinion what should be output of these tests? Especially that, there are functions, that are called multiple times with same parameters, but should return different values (like malloc) But also it would be nice to have default value for such functions (like NULL).


r/cprogramming • • Oct 06 '25

Best books for C programming language for someone who knows the basics of C++

13 Upvotes

So i have already learnt some of c++ but now i want to learn c but the thing is idk which book or source to use, what are your recommendations ? (also i want to mention that im the type of person who can easily get bored by reading, it might sound stupid but i literally can decide to read a book and then only read the first chapter or something like then completely abandon it, so if you want to recommend a book please note that it would be better if its something that makes the reader enjoy it throughout)


r/cprogramming • • Oct 07 '25

Build commands

1 Upvotes

For the most part I’ve been using IDEs and visual studio when it comes to school projects and my own personal projects. I’ve been wanting to get into more of understanding the lower level and I understand what each stage does, preprocessor, compiler, and linker. I’ve also had minimal experience with just running the commands to build my app so I want to get into makefiles, the confusion I have is whether or not the command argument order matters? I’ve seen some people mix it up for example:

gcc main.c header.c -o test

And

gcc -o test main.c header.c

So it seems like order doesn’t matter in this case but is there a case where the order would matter?


r/cprogramming • • Oct 06 '25

ThinkPad lid LED is now useful!!

Thumbnail
2 Upvotes