SShortSingh.
Back to feed

The 'void' Keyword in C Has Four Uses — More Than You Might Expect

0
·1 views

The 'void' keyword in C has four distinct uses, which is one more than the often-cited three uses of 'static'. The keyword was not part of the original K&R dialect of C, where functions with no return value simply omitted the return type and were assumed to return int. Stephen Bourne, creator of the Bourne Shell, pushed for its addition after finding this ambiguity frustrating, and Dennis Ritchie agreed since explicitly returning nothing could save a machine instruction. Later, 'void' was reused to indicate that a function takes no parameters when C adopted function prototypes back-ported from C++, ensuring backward compatibility with older code. The keyword has since influenced several other programming languages, including Java, C#, D, and Swift.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Developers Debate Best Practices for Structuring Frontend Projects

A discussion has emerged in the developer community around how frontend projects should be organized, a topic seen as less explored than its backend counterpart. Common approaches include organizing code by file type, by feature, or following framework-specific conventions such as Angular's predefined structure. The conversation also touches on whether advanced methodologies like Domain-Driven Design and Clean Architecture are practical for frontend applications or represent unnecessary complexity. Some developers suggest that a straightforward feature-based structure may be sufficient for most use cases. The debate highlights a broader need for clearer, widely accepted architectural guidance in frontend development.

0
ProgrammingDEV Community ·

AI-generated service wiped database on startup yet passed all 18 automated tests

A software developer testing an AI-generated billing service discovered it dropped and recreated all database tables on every startup, effectively destroying existing data. Despite this critical flaw, the service passed all 18 automated test scenarios because each test built its own state from scratch in an empty database. Since repeatable tests always start clean, the destructive startup behavior was indistinguishable from a normal fresh start, leaving the defect completely untested. The root cause was the AI agent interpreting a schema description as an instruction to create tables at launch, unaware that existing rows might already be present. The author concludes the fix is not writing more tests, but asking a different question — one that verifies behavior against a pre-populated database rather than an empty one.

0
ProgrammingDEV Community ·

CircuitVerse Implements LTI 1.3 Login Endpoint, Fixes Security Gaps Found by CodeQL

CircuitVerse shipped the first stage of its LTI 1.3 integration this week, implementing the /lti/login endpoint that handles the OpenID Connect initiation request from a Learning Management System. The controller, built in around 64 lines of code with 150 lines of tests, redirects the LMS to an authorization URL after resolving the incoming credentials to a registered deployment. A CodeQL scan flagged a potential CSRF vulnerability caused by broadly skipping token verification, which was resolved by overriding the verification predicate to apply only to the specific parameters expected in an LTI login request. Code review surfaced three additional issues — ambiguous deployment lookups, unvalidated authorization URLs that could allow redirects to malicious endpoints, and registered query parameters being silently dropped — all of which were addressed before merging. A separate debugging session traced a database schema mismatch to an abandoned proof-of-concept migration from earlier in the project, highlighting the risk of leaving experimental migrations applied to a development database.

0
ProgrammingDEV Community ·

How One Developer Built a Battery-Friendly Geofencing Engine to Auto-Silence Android Phones

A developer built an Android app called Muffle after a embarrassing phone interruption at a library highlighted how poorly smartphones handle context-aware sound management. Instead of using constant GPS polling, the app leverages Google Play Services' GeofencingClient API, which lets the operating system monitor location boundaries using low-power hardware sensors. A local Room database stores sound profile rules offline, with no cloud dependency, and the AudioManager service applies volume changes in milliseconds once a geofence boundary is crossed. The developer encountered GPS drift issues in dense urban areas, where tall buildings caused false geofence exits, and resolved this by introducing a dwell-time requirement before any profile change fires. A custom priority queue ensures the most restrictive sound profile wins when multiple location-based routines overlap.