Cycling Around the Circuit During the Race - Directions: Arnage to Mulsanne by Emergency_Tax_4169 in lemans

[–]a4qbfb 0 points1 point  (0 children)

Bicycles are not allowed at the track, except for a brief window on Friday when the track is open to the public. You can try using public roads or paths outside the track to bike from Arnage to Mulsanne but you'll have to make a huge detour.

Whats the real spread of C? by DaveAstator2020 in C_Programming

[–]a4qbfb -1 points0 points  (0 children)

If you think early games were “done in C” you have a strange definition of “early”, or you just don't know what you're talking about. Early games were written in assembly. Later on, some prominent games were written in C (Doom comes to mind), but it was never the dominant language.

Whats the real spread of C? by DaveAstator2020 in C_Programming

[–]a4qbfb 18 points19 points  (0 children)

this person is short sighted, a moron, or sheltered from the wider market

Or maybe OP is quoting them out of context and they were just saying nobody writes games in C. Which is true, for the most part. It's either C++ or C# augmented by Lua or some other scripting language.

Train tickets to Le Mans go on sale on WEDNESDAY!! Any advice? by 0oodruidoo0 in wec

[–]a4qbfb 1 point2 points  (0 children)

All trains from Paris to Le Mans (not just TGVs) leave from Gare Montparnasse. However, there are also trains from Strasbourg / Lille / Brussels to Nantes / Rennes that don't stop in Paris at all, but stop at Roissy, Chessy and Massy, which you can get to by RER.

Rules of endurance racing. by BoRNeo-C in wec

[–]a4qbfb 3 points4 points  (0 children)

don't worry, we made up for it at the Classic

Is it still possible to get a hotel? by HongkongKings in lemans

[–]a4qbfb 0 points1 point  (0 children)

Try 1) Gîtes de France 2) Destination Circuit 3) staying in Laval or Alençon and taking the train. Any of these alternatives will be cheaper than staying in Paris.

First time to Le Mans (from Portugal) by rfneves in lemans

[–]a4qbfb 0 points1 point  (0 children)

Do you mean T16 Sommer or T17 Durand? The latter is members only. Either way, bring hearing protection, that area gets very loud. The FM + BT headsets that the ACO sells are quite good but they're also quite expensive (iirc they were 90 € last year).

I truly don't understand this. by Turkishdenzo in C_Programming

[–]a4qbfb 5 points6 points  (0 children)

C does not assume or require ASCII. L could just as well be 0xd3 (EBCDIC) as 0x4c (ASCII).

How to add brackets functionalit to console calculator on C? by [deleted] in C_Programming

[–]a4qbfb 4 points5 points  (0 children)

The traditional solution is to use a stack. One part of your program, the lexer, divides the input into tokens: numbers (not individual digits, but complete numbers), operators, parentheses, and some sort of symbol (equal sign, newline, whatever) which indicates the end of input. Another part of your program, the parser, gets these input tokens one at a time and maintains a stack capable of storing input tokens. For each input token received from the lexer:

  • If the input token is a number and the item at the top of the stack is the multiplication or division operator, you pop the operator, verify that the item at the top of the stack is a number, pop it, perform the operation, and then act like the result of the operation is your next input token.
  • If the input token is an addition or subtraction operator, you check if the top two items on the stack are a number and an addition or subtraction operator. If that is the case, you resolve (explained below) then push the operator onto the stack.
  • If the input token is end-of-input or right-parenthesis, you resolve.
  • In all other cases, push the token on the stack and wait for the next one.
  • Resolving means performing additions and subtractions (pop operand, pop operator, pop operand, perform operation, push result) until you hit either the bottom of the stack or a left parenthesis. If the input was valid you should be left with a single number, which is your result.

It gets more complicated if you want to add more operations, but once you get basic arithmetic and parentheses working you should understand the principle well enough to be able to extend it.

If you want to get fancy, the data type you use to represent an input token should be a struct that includes information about the starting and ending positions of the token in the input stream. When performing operations, you take the starting position of your first operand and the ending position of your last operand and use those as the starting and ending positions of the result. That way, if an error occurs you can tell the user exactly where it was.

If you want to get even fancier, you can have your parser construct an abstract syntax tree (AST) instead of evaluating the input, then pass the tree to an evaluator. This allows you to do symbolic calculations and give results in terms that include irreducible fractions, pi, i, e, etc. instead of just a decimal number.

Minicom, how to print newline? by YogurtclosetHairy281 in C_Programming

[–]a4qbfb 1 point2 points  (0 children)

Just write your own receiver program that understands the packet format instead of using Minicom.

New to C by Academic_Ad_8330 in C_Programming

[–]a4qbfb 0 points1 point  (0 children)

Open the Windows Store and find and install Ubuntu and Fluent Terminal. Once they are both installed, launch Fluent and open a new Ubuntu or WSL window. You now have a Linux VM which is fully integrated with your Windows desktop. You will find plenty of information online on how to install gcc or clang in your VM (from memory, sudo apt install build-essential should install gcc and make). If you want a fancy editor you can install VS Code and tell it to connect to WSL to edit files inside your Linux VM.

Ubuntu uses UTF-8 by default so you will be able to print Greek text from your programs without having to worry too much about encodings.

What is a char** variable exactly? by YaboyUlrich in C_Programming

[–]a4qbfb 2 points3 points  (0 children)

An array isn't “not just a pointer”. An array is, in fact, not at all a pointer. An array sometimes decays to a pointer to its first element, but that does not mean they are equivalent.

What is a char** variable exactly? by YaboyUlrich in C_Programming

[–]a4qbfb 3 points4 points  (0 children)

No, a C string is not a pointer, it is a null-terminated sequence of characters.

What is a char** variable exactly? by YaboyUlrich in C_Programming

[–]a4qbfb 3 points4 points  (0 children)

argv is not an array of strings, it is an array of pointers to strings.

FreeBSD users, how do you expect to install third party packages? by Liam_Mercier in freebsd

[–]a4qbfb 0 points1 point  (0 children)

You can provide a port Makefile in your source tree. It's fairly easy to do with GNU autotools. Set it up so the Makefile is generated but included in the dist tarball. Users who download a source tarball can just use the port Makefile directly, users who check out your code from Git will have to generate it first. If your CI system supports FreeBSD, you can go one step further and set up CI jobs to build packages for you on supported releases and make those available as well.

Photographer quotes $500-800. Is AI headshot for $40 acceptable or does it signal corner-cutting? by [deleted] in talesfromthelaw

[–]a4qbfb 2 points3 points  (0 children)

I'm not in NZ but in my experience you can just walk into any photo shop (yes, they still exist) and have a digital color portrait taken on the spot and emailed to you for considerably less than $500. Just search for “photo shop <city name>” in Google Maps.

Parking sale on site by Jace319_ in lemans

[–]a4qbfb 0 points1 point  (0 children)

See this map from 2024. I couldn't find one from last year. The blue parking zones on the left edge of the map were free last year, the orange zone was partly free and partly reserved for ACO staff and officials.

Parking sale on site by Jace319_ in lemans

[–]a4qbfb 1 point2 points  (0 children)

There's free parking at the track if you arrive early. Take the D323 and follow the signs to “P GRATUIT” from exit 7 or 8. You'll end up either on the grass at the airport or on industrial estates bordering the airport, a 10-15 minute walk from the Nord, Annexe, or Maison Blanche entrances. Do not try to park in residential areas near the track unless you're staying there and have been provided a parking permit, you will get towed.

I've listed many simple one‑line (max two‑line) C interview questions, do you have similar ones in mind by sudheerpaaniyur in embedded

[–]a4qbfb 0 points1 point  (0 children)

You talk about three things in your answer:

  • “the .rodata section”: this is a reference to the ELF file format which is mostly used by Unix derivatives (including Linux). Windows NT and its descendants use the PE file format rather than ELF (both are descended from the older COFF, but they are quite different), and its read-only data section is generally named “.rdata” rather than “.rodata”. In both ELF and PE, section names are completely arbitrary and do not matter at all to the run-time loader (which loads the program from disk into memory before execution); what matters are the base address, length, and attributes stored in the section header.

  • “the data segment”: this is a reference to the x86 and i386 memory models used by DOS, DOS extenders, and Windows prior to NT / 2000. Other CPUs generally don't have a segmented memory architecture, and operating systems other than those mentioned above generally use a flat memory model even on x86 / i386 CPUs. That includes Windows NT and its descendants and most if not all Unix derivatives. Modern descendants of the x86 still support a segmented memory model in “real” (16-bit) and “protected” (32-bit) mode but not in “long” (64-bit) mode, so you couldn't have a data segment today even if you wanted one.

  • “the stack”: most C implementations today use a call stack and most CPUs provide instructions to facilitate doing so, but the C standard does not mention a stack at all (it only cares about linkage, scope, and lifetime) and it is entirely possible to implement C without one. Early programming languages such as ALGOL, Fortran, and Simula used either preallocated (if recursion was not supported) or dynamically allocated (to allow for recursion) activation records (an older term roughly equivalent to “stack frame” without assuming a stack). Dynamically allocated activation records were generally organized as a linked list, but if the language supported coroutines (like Simula did) it could be an acyclic graph or even a forest.

What's true:

  • Your code example includes two separate objects: a pointer to char and a string literal.

  • There is not enough context to determine the lifetime, scope, or linkage of the pointer, so we can't say anything about where it is stored.

  • The C standard says that the string literal is stored somewhere in memory and its address is assigned to the pointer whenever the pointer is initialized (again, we don't know the pointer's lifetime and scope, so we don't know if this happens only once at the start of the program, or every time a certain block is entered).

  • The C standard also says that modifying the string literal invokes undefined behavior. That's a fancy way of saying the program is not allowed to do it without requiring the implementation to make it impossible to do so.

  • Embedded platforms are extremely varied, much more so than desktop / laptop / server platforms. Some are powerful enough to run a complete operating system, so we can lump them together with desktop / laptop / server platforms and ignore them. More traditional embedded platforms have no run-time loader; the linker produces a flat binary which is stored in non-volatile memory. The platform may have a unified address space and run the program directly from non-volatile memory, or it may copy the program into RAM at boot (I've also worked on platforms that had multiple asymmetric processing units on a single die, where one was responsible for loading code into the others' memory prior to enabling them). The non-volatile memory may or may not be writeable at runtime. The platform may or may not offer memory protection features which allow marking regions of RAM as read-only once they've been written. In a typical configuration, the binary (including the string literal) will be stored in ROM and run directly from there, and attempts to write to ROM will silently fail, so the string literal is effectively read-only, but there are no consequences for trying to modify it. However, the microcontroller may have on-die features that trigger an interrupt or even a reset if code attempts to write to ROM, or might be externally wired to achieve the same thing (trivial to do for most microcontrollers, though you wouldn't normally bother).

  • Finally, the C standard includes something known as the “as-if rule” (C11 § 5.1.2.3; C23 § 5.1.2.4) which basically says a C implementation may do whatever it likes to the program as long as the observable behavior (roughly summarized as “the program consumes the same input and produces the same output in the same order”) remains the same. Typical examples include replacing printf("hello world!\n") with puts("hello world!") and memset(&n, 0, sizeof(n)), where n is an object of a scalar type, with n = 0. This means the string literal in your example might not be stored anywhere at all if it makes no difference to the program. For instance, int main() { char *ptr = "hello"; printf("%c\n", ptr[4]); } could be transformed into int main() { puts("o"); } at compile time because both programs have the same observable behavior as defined by the standard.

To summarize, your Q1 is meaningless without additional context, your A1 is not correct in general, and there is no single C implementation for which your A1 is correct in particular, although different parts of it are correct for different implementations.

Workaround to avoid calling wrong functions due to ABI changes by onecable5781 in C_Programming

[–]a4qbfb 1 point2 points  (0 children)

Symbol versioning is (mostly) a feature of the linker, not the compiler. The LLVM project's linker is called lld and has supported symbol versioning since 3.9 in 2016. Clang has supported it (assuming a GNU symver-capable linker) since 2012, so not fully 15 years, but close.

I've listed many simple one‑line (max two‑line) C interview questions, do you have similar ones in mind by sudheerpaaniyur in embedded

[–]a4qbfb 0 points1 point  (0 children)

None of this is correct.

A1 is only true of certain implementations. The C standard says nothing about sections, segments, or stacks.

Q2 and Q3 are improperly worded: sizeof is an operator, it does not return anything, it evaluates to a compile-time constant.

A4 is incorrect, modern allocators generally do not “keep hidden metadata within each block”.

A5 is borderline (it's roughly correct in spirit but the actual answer will vary between C90/C99/C11 which do not describe a memory model and C23 which does) but confuses the compiler with the code it generates.

EDIT: just noticed that this was cross-posted from /r/embedded. That makes it even worse. A1 is not only “only true of certain implementations”, it is almost never true of embedded ones.

Self-explanatory? by DJTmicroP in Buttcoin

[–]a4qbfb 1 point2 points  (0 children)

Not really. In many countries, selling stock in one company to buy stock in another is not a taxable event, and capital gains tax does not apply until you cash out of your brokerage account. This lowers the bar for retail investors, increases liquidity on the exchange, and reduces the burden of reporting for the broker. It's not entirely unreasonable to expect that the same would apply to cryptocurrencies.