Questions tagged [c]
C is a general-purpose computer programming language used for operating systems, games and other high performance work.
                1,327 questions
            
            
            
                4
            
            votes
        
        
            
                6
            
            answers
        
        
            
                853
            
            views
        
        
            
            
            
        Can a language be sound if it doesn't promise safety?
                    It is said that C's type system is unsound, which means that it has "false negatives", it tells the programmer everything is fine, but then the code fails at runtime. for example, "the ...
                
            
       
        
            
                -1
            
            votes
        
        
            
                1
            
            answer
        
        
            
                133
            
            views
        
        
            
            
            
        How to organize struct-based "methods" in C similar to object-oriented style? [closed]
                    So I was coding in C for a while now, getting used to language syntax and different styles.
Implemented a couple of simple data structures, algorithms and tried my skills in making Minesweeper clone.
...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                629
            
            views
        
        
            
            
        Should I include the header of the source file always in C/C++?
                    I have a source file that is used by other sources so it has a header file. If in the header, there are types used that needs inclusion of other headers, I'm better to include this header in its ...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                563
            
            views
        
        
            
            
            
        Why does C allow escaping apostrophes / single quotation marks in string literals
                    As far as I can tell, the strings "It's me" and "It\'s me" are always identical. There seems to be no reason when a programmer needs to escape '. Yet, I could not find and ...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                371
            
            views
        
        
            
            
            
        Is Feeding a Watchdog Timer from an Interrupt Service Routine a Bad Practice?
                    In an embedded system, I require a watchdog to be able to pass ESD qualifications. Having no experience with watchdogs, I went through this Memfault article. I liked the events "registration"...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                173
            
            views
        
        
            
            
        What architectural connector is a file descriptor?
                    The software architecture literature has lots of information on software connectors as in component and connector views of architecture.
What kind of connector is a file descriptor? I noticed in the ...
                
            
       
        
            
                6
            
            votes
        
        
            
                4
            
            answers
        
        
            
                710
            
            views
        
        
            
            
            
        Why is there (practically) no 6-byte integer in common usage?
                    In Postgres, it used to be quite common to use a 4-byte integer auto field for primary keys, until it started becomming somewhat common to run into the 2147483647 limit of 4-byte integers. Now, it's ...
                
            
       
        
            
                1
            
            vote
        
        
            
                3
            
            answers
        
        
            
                413
            
            views
        
        
            
            
        Get call graph / path of C with function pointer
                    I have a C codebase with function calls made through function pointers. I tried using LLVM AST and IR with Python to generate a function call graph, but handling the function pointer calls requires ...
                
            
       
        
            
                0
            
            votes
        
        
            
                2
            
            answers
        
        
            
                302
            
            views
        
        
            
            
            
        What should I consider when determining what `ALLOC_MAX` should be in this type of I/O loop?
                    For, e.g. determining an amount of memory that is safe to allocate for processing file or device with this type of I/O loop:
 HANDLE hFile /* = file open with GENERIC_READ */;
 LARGE_INTEGER liSize;
 ...
                
            
       
        
            
                1
            
            vote
        
        
            
                5
            
            answers
        
        
            
                388
            
            views
        
        
            
            
            
        Anti-pattern? Double header and exposed implementation detail
                    Consider that I've implemented SHA-256 hashing in C as incrementally updated IUF (init-update-finalize) working context and 3 subroutines. To use it in free-standing environment, or to efficiently use ...
                
            
       
        
            
                7
            
            votes
        
        
            
                2
            
            answers
        
        
            
                719
            
            views
        
        
            
            
            
        When the stack frames become computationally expensive
                    I've been experimenting with different data structures and algorithms in Python, Java and C to see in what circumstances function/method inlining could bring meaningful gains in terms of the execution ...
                
            
       
        
            
                3
            
            votes
        
        
            
                1
            
            answer
        
        
            
                207
            
            views
        
        
            
            
        C++: Good approach to handle libxml2 resource management in a wrapper
                    I try to write a C++ wrapper to a well-known C library, libxml2. In libxml2, an xmlDocPtr represent an XML document and xmlNodePtr represents a node. An xmlDocPtr contains a root xmlNodePtr and every ...
                
            
       
        
            
                2
            
            votes
        
        
            
                3
            
            answers
        
        
            
                270
            
            views
        
        
            
            
            
        How to decouple spagheti code for unit tests [duplicate]
                    A little background on the project: we as a company receive a spaghetti source code, and into that we add even more spaghetti code. So with that I want to say that
complete restructuring and ...
                
            
       
        
            
                0
            
            votes
        
        
            
                4
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
        Is it a bad practice to return an enum without an enum return type?
                    I'm specifically asking about C.
Example:
enum numbers {
    EVEN,
    ODD
};
int isFiveEvenOrOdd(void) {
    if (5 % 2 == ODD) return ODD;
    else return EVEN;
}
int main(void) {
    printf("%...
                
            
       
        
            
                4
            
            votes
        
        
            
                4
            
            answers
        
        
            
                1k
            
            views
        
        
            
            
        Is updating a macro value in the Xcode preprocessor's macros violating the open–closed principle?
                    For example, for some Xcode projects, if I have some places that defines a number at some .cpp files:
const int PAGE_MAX=5;
and a new requirement comes that needs to change PAGE_MAX, I need to modify ...
                
            
       
         
         
         
        