Zum Hauptinhalt springen
Intelligence View
⚡ tsecurity.de Intelligence

Notes on source code preprocessing

(This post contains some reflections on the hypothetical design of an ideal programming language...)Don't use or support the use of preprocessing source code.…

Beitrag
0
Seite
0
↗ Quelle (vegardno.net)
Cloud & Tech-Stack · 3 Min. Lesezeit
Quelle: vegardno.net
Rubrik: Unix & Linux Server
(This post contains some reflections on the hypothetical design of an ideal programming language...)

Don't use or support the use of preprocessing source code. Preprocessing means that all the tools which operate on the source code (including editors, compilers, static analyzers, etc.) will necessarily need to either support preprocessing themselves, or call the preprocessor before operating on the resultant source code.

Consider, for example, a simple tool that parses C code and searches for a given text in all the literal strings found in that code. If the source code needs to be preprocessed, then certain parts of the code may not be searched if the part in question is contained within the equivalent of a C-preprocessor #ifdef/#endif block. On the other hand, if we want our tool to also find strings inside these sections, then we can no longer use a C parser because #ifdef and #endif are not recognized by the C parser proper.

(The solution to the problem might include using regular expressions as a kind of heuristic to determine where the strings are, and then do concatenations, etc. However, this is only an approximate solution, and is in general not entirely satisfying. What about the more complex task of looking for specific variable or function declarations? In fact, a number of such tools have had to deal with variations of this problem; see for example LXR and Coccinelle.)

Multiple, different types of preprocessors also don't mix very well. For example, as an extension to many programming languages, the source code is preprocessed so that SQL queries are substituted with the (possibly verbose) support code which would otherwise be needed to prepare and execute the query in question. Now we have exactly the same problem as mentioned above, which is that support tools (editors, compilers, etc.) will have to either support the preprocessor language or (more likely) always operate on already-preprocessed source code, with all the aforementioned drawbacks. In some cases, the order of preprocessing will also become significant, or different preprocessor languages might be incompatible.

Another practical aspect of preprocessing is that the code which is inside such #ifdef blocks will be compiled only conditionally; the compiler might not even look at it. This means that the compiler is a lot less useful than it could be. It is one of the main tasks of the compiler to inform the programmer when he/she is writing something which is internally inconsistent, such as calling a function with the wrong argument types. (This is entirely possible if there is a caller of the function inside an #ifdef block and the definition of the function was later changed to take different arguments.)

In conclusion, I think C/C++ could have done a lot better in this area. On the other hand, a lot of other programming languages did get it right. But maybe the need for alternative compilation is greater in the lower-level languages and it's really just a trade-off between performance and usability.
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:
✏️ Information ergänzen
🛡️ Versioniert via CMS-Revisions-Engine (Freigabe-Queue für Gäste)

💬 Topluluk tartışması ve yorumlar

🌐 Ana sohbete katıl

Tartışmayı başlat: Social Chat yayın akışı veya yukarıdaki ekleme formuyla uzman katkısı gönder.

Security Briefing Ücretsiz · Tek tıkla abonelikten çıkma

Zeka Digest - ücretsiz

Günlük en önemli güvenlik haberi · herhangi bir zamanda alınabilir

Community Rating & Social Proof
⭐ Okuyucu Puanı
–
Ø / 5.0
Hiçbir okuyucu henüz yorum yok
Bu makale yararlı mıydı?
0
Değerlendirmenizi gönderin
Detaylı değerlendirme (isteğe bağlı)
İçerik ve Kalite
Kaynak ve Güvenilirlik
Güncellik

İlgili Story Cluster & Kaynaklar (vector AI)

6 Cluster
28 Kaynaklar
GOG Black Friday sale is live, plus multiple Lara Croft games enter the GOG Preservation Program
GamingOnLinux Latest Articles 42 dakika önce
27 diğer kaynaklar
Latest from TechRadar57 dakika önceBlack Friday Sonos: the best deals on wireless speakers, soundbars and more Latest from TechRadar52 dakika önceBlack Friday discounts on Seagate's Expansion Desktop Hard Drive make it one of the cheapest of its kind, with discounts of up to 22% on higher storage capacities Latest from TechRadar48 dakika önceThe best Black Friday Philips Hue deals: save on smart bulbs, string lights, and light strips Latest from TechRadar46 dakika önceNewegg knocks $348 off its AMD Ryzen 7 5800X3D PC bundle for Black Friday Latest from TechRadar44 dakika önceThe best early Black Friday Garmin deals, picked by a smartwatch tester Latest from TechRadar35 dakika önceWork like it's 1998: Aura Displays' retro-inspired Bondi Blue Triple Aero ’98 Pro Max laptop screen extender gets a 16% discount for Black Friday Latest from TechRadar34 dakika önceThe Disney+ and Hulu Black Friday streaming deal for just $5 has returned Golem.de44 dakika önceAnzeige: Beliebter WLAN-Repeater für nur 23,32 Euro im Black Friday Angebot Android55 dakika önceBose Black Friday: Diese Kopfhörer, Soundbars und Boxen sind heute reduziert Latest from TechRadar1 saat önceBlack Friday phone deals: 35 hand-picked deals on Apple iPhones, Pixels, Samsung phones, and more PC-WELT1 saat önceBlack Friday: Saugroboter von Dyson, Roborock und Mova heute zum Amazon-Tiefstpreis PC-WELT1 saat önceBlack Friday: Saugroboter von Dyson, Roborock und Mova heute zum Amazon-Tiefstpreis Latest from TechRadar1 saat önceApple's lightweight 2026 M5 MacBook Air gets $250 off for Black Friday Engadget1 saat önceFive solar generators going for deep discounts on Black Friday The Verge1 saat önceXteink’s pocketable X4 Classic e-reader is down to just $55 for Black Friday PC-WELT1 saat önceMein liebstes Produktivitäts-Gadget: Stream Deck zum Black Friday günstiger PC-WELT1 saat önceApple Mac mini wird immer günstiger: Diese Mini-PCs sind im Black-Friday-Sale PC-WELT1 saat önceMein liebstes Produktivitäts-Gadget: Stream Deck zum Black Friday günstiger Codrops2 gün önceBlack Friday 2026: 10 Deals for Web Designers and Front-End Developers CNET12 gün önceSave $112 on Sony’s Flagship WH-1000XM6 Headphones This Black Friday CNET1 saat önceSave $56 on Baseus Inspire XC1 Open Earbuds With This Black Friday Deal Golem.de1 saat önceAnzeige: Ankers Soundcore-Lautsprecher zum Black Friday für 18 Euro bei Amazon PC-WELT2 saat önceBlack Friday: MacBook, Surface & Co. jetzt bis zu 630 Euro günstiger Latest from TechRadar2 saat önceThousands of Black Friday deals are live right now. These are the 175 best Latest from Windows Central2 saat önceXBOX 25th anniversary hardware has a perfect companion for mobile gaming — and it's 20% off for Black Friday PC-WELT2 saat önceDas beste Tool, das ich je für unter 14 Euro gekauft habe – jetzt als Black-Friday-Schnäppchen CNET2 saat önceShop Top Apple Watch Black Friday Deals, Starting at $179
3 Kaynaklar
Twilio's New 10DLC Rejection Codes (Dec 2026): What Each Means and How to Avoid Paying for a Rejection
DEV Community 32 dakika önce
2 diğer kaynaklar
Benzer katkılar
🔍 Verwandte News

Auch interessante Nachrichten Notes on source code preprocessing

Thematisch verwandte Begriffe: Notes, source, code, preprocessing · 6 Treffer

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Yorumlar yüklenir..
Update to Update
Widgets & Topics
Loading widgets…
Nächster Beitrag