Nzira yekudzidza C kuronga uye izvo zvekutanga masisitimu anoshanda nenzira inoshanda?

Chirongwa chekugadzira

Pane nzira dzakawanda dzekuita dzidza kuronga, kune akawanda mapeji ewebhu ane dzidziso, mienzaniso yekodhi, nezvimwe. Iwe unogona zvakare kuwana akasiyana siyana emabhuku pane chirongwa, zvese zviri C uye mimwe mitauro yakawanda. Kune zvakare epamhepo kana kumeso-ku-kumeso zvirongwa zvehurongwa kwaunogona kutanga kunzwisisa aya matekiniki ekugadzira yako wega software kubva pakutanga kusvika padanho repamberi.

Zvino, kune rimwe divi, kune vamwe vadzidzisi vemuviri vane mamwe ma microprocessor kana ma microcontroller ayo aunogona kuronga kuti udzidze hunyanzvi uhu nekutamba nekugadzira mapurojekiti. Muenzaniso wakanaka kwazvo ndeye Raspberry Pi pachayo, mabhodhi eParallaz, kana iwo emunyika ayo iwe aunowana muchitoro cheMKElectronics, kana bhodhi rinozivikanwa Arduino, Scratch. Nekudaro, kana iwe uchida kutarisa zvakanyanya pasoftware kuvandudza, ini ndinogara ndichikurudzira zvakafanana: verenga uye gadzirisa kodhi.

Munyaya iyi Ini handizoyedze kukupa iwe kuronga makirasi, sezvo iriyo nyaya yandaizopa yezvinyorwa zvakawanda senge izvi zvichitsanangura kubva hwaro hwekuronga kune epamberi chirongwa. Ndiri kungoda kukupa iwe zviwanikwa kana nzira dzekutanga kusimbisa ruzivo rwako. Uye ini ndinokuvimbisai kuti anoshanda kwazvo. Zvakare, iwe unoziva kuti iwe unogona kutanga nechero GNU / Linux distro, nemapakeji anodiwa ekuronga senge chinyorwa mhariri, kana IDE, zvakare GCC neGDB, kana iwe uchida kugadzirisa ... Kana zvakare shandisa zvimwe kugoverwa kwevagadziri. Ini zvakare ndinofunga kuti iwe unotoziva kana kuti unofanirwa kuziva mhando iyi yezvishandiso zvaunazvo iwe zvaunazvo.

Kutanga sei?

On-screen sosi kodhi

Unogona kuwana kodhi snippets mune network kune mamirioni, ndokuti, zvidimbu zvekodhi zvinogona kushandiswa kana kushandurwa kuti zviite chaizvo mabasa. Aya masosi enzi ndiwo hwaro hwekudzidza, nekuti iwo akakosha mabasa ayo achakubatsira iwe kunzwisisa mashandiro anoita zvirongwa uye iwe unogona kugadzirisa mamwe ma parameter kuti aite kuti vaite chimwe chakasiyana. Uye ndozvazvinotanga!

Sezvaunofambira mberi, unogona kusvetukira mukati verenga sosi kodhi, iyo kana ikataurwa zvakanaka ichave inonyanya kuvaka pazivo yako. Nehurombo havasi vese vanogadzira vane tsika yakanaka yekupindura pamitsetse yavanonyora, uye mune zvimwe zviitiko zvirevo zvacho zvinoshomeka kana kuvhiringidza kunyangwe kune vanhu vane ruzivo. Asi nerombo rakanaka isu tine chikamu chakakura chenharaunda icho chinotaura pamusoro pezvirongwa zvavo zvakanaka.

Mapuratifomu ane software kodhi senge GitHubSemuenzaniso, kunyangwe paine zvimwe zvakawanda, iwo manyuko akakosha kwazvo ehungwaru. Muchokwadi, ini ndinokurudzira kuti kana iwe uchinge wawana kumwe kutsetsenura nezvidimbu kana zvirongwa zvako zvidiki, enda kune aya marudzi emapuratifomu uye uwane kodhi yekodhi yemapurojekiti akareruka. Iwe unogona kushandisa iyo firita uye yekutsvaga injini mabasa kuti uwane yakatarwa kodhi mune mutauro wechirongwa, se C wobva wasarudza iri nyore.

Saka zvishoma nezvishoma unogona kuenda kuwedzera kuoma kwezvirongwa kukwidza ruzivo rwako kusvika padanho repamusoro. Usatanga nemapurojekiti ane mitsara yakawanda, kana iwe unozoshungurudzwa nekusanzwisisa kuti iyi yakawanda sei kodhi ndeyei kana zvainoita. Inotanga nezvirongwa zvidiki zvemitsetse gumi nemaviri, ipapo kune mashoma zana kana kupfuura uye zvichingodaro kusvika padiki padiki iwe uchisvika kune mamwe mapurogiramu akaomarara.

Uye zvakare, ini ndinokuraira iwe kuti utsvage mapurogiramu aunoziva kwazvo maererano nekushandisa kwavo. Semuenzaniso, fungidzira urikushandisa imwe yakavhurwa sosi mameseji edhita kana calculator. Kuziva zvinoitwa nechirongwa ichi mukuita kunoita kuti zvive nyore kwauri kurondedzera mitsara yekodhi yekodhi iwe yauchazoona nemabasa ane chirongwa ichi. Kune rimwe divi, kana ukasarudza kodhi iwe yausingazive nezvayo, chete nerubatsiro rweyako yekutanga programming ruzivo uye zvirevo zvaunowana mumafaira ekodhi hazvikwani.

Semuenzaniso, tarisa kune wechipiri muenzaniso unoratidzwa mukutsvaga kwangu kwehurongwa hwekuverenga mu mutauro C yemufananidzo unotevera. Tsananguro inoratidza kuti chirongwa chemutsetse wemirairo icho chinoshandisa nyore Calculator. Iyi kodhi yakanaka kutanga nayo, kwete chete nekuda kwekureruka kwekodhi, asi nekuti kuve wakanyora-unyore hauzove nemafaira ekodhi ane chekuita neGUI, nezvimwe, zvese zvinokuvhiringidza uye zvinoita kuti kudzidza kuve kwakaoma.

Github

 

Kana isu tikapinda muchirongwa ichi kuti tione kodhi yayo, isu tinotanga tawana mafaera ayo mushambadzi akaisa papuratifomu iyi. Kunge ruzivo rweLICENSE rezinesi, iyo faira ine ruzivo par kugona README, nezvimwe. Asi cherekedza kuti iripo mahedhiyo mafaira sevabatsiri.h uye struct.h, izvi zviviri zvakakosha, uyezve maviri .c, ayo ari iwo chaiwo C kodhi kodhi yechirongwa ichi:

Misoro

 

Kana isu tikasvika kune imwe yemusoro kana .h, tichaona kuti iri chirongwa chiri nyore, isina mitsara yakawandisa. Iwe uchawana aya marudzi emafaira kazhinji, kunze kwekunge chiri chirongwa chakapfava chisingade iwo, asi iri inosanganisira faira uko mamwe marongero kana mamwe mafaera akaverengerwa kuti muunganidzi anofanirwa kugadzirisa kuti aite yekupedzisira bhinari yechirongwa.

Mune iyo musoro wefaera iwe unowana yakananga kirasi kuzivisa, subroutines, zvinotsanangurwa akasiyana, nevamwe. Dzimwe nguva idzi .h dziri raibhurari iyo iwe yaunogona kushandisa kubva kune yakakosha kodhi faira (.c) uchiita kunongedzera kwakananga kune izvo zvinotaurwa mukati memisoro iyi usingatombofaniri kudzokorora chimiro chose nguva dzese pazvinenge zvichidikanwa:

Code musoro

Panyaya yekodhi yekodhi pachayo, senge iyo calc.c faira kubva pamuenzaniso wedu, iwe unowana mamwe mitsara. Dzinenge mazana mana chinhu, uye mune ino chaiyo kesi ivo havana kutaurwa. Izvo zvinotadzisa zvakanyanya kunzwisisika kwekodhi. Nekudaro, kuve chirongwa chiri nyore senge karukureta, unogona kuverenga nekuchigadzirisa pasina matambudziko, nekuti ichave inonzwisisika:

 

Rangarira verenga kodhi uye uigadzirise. Avo ndiwo makiyi ekudzidza kuita chirongwa munzira yakanakisa ...

 

Imwe nhanho: iyo kernel

Linux Kernel

Zvino, kana iwe watove nekuwana humwe hunyanzvi hwekuronga hunyanzvi muC mutauro, unogona kutora nhanho yekuwedzera wopinda inonakidza nyika masisitimu anoshanda uye maumbirwo emakomputa. Kune izvi unofanirwa kuve neruzivo rwepamusoro rwekuti mashandiro emakomputa anoshanda sei, asi zvakare izvo zviripo zvakavhurika sosi mapurojekiti anogona kutibatsira zvakanyanya.

Ongorora kernel kodhi kodhi Zvinogona kutiita kuti tinzwisise nenzira iri nani mashandiro anoita ino nyika masisitimu anoshanda, uye vanozovewo nyanzvi dzemakirasi ekuti tiwane "doctorate" yedu muC programming, sezvo chiri chinhu chemazwi makuru. Iwe unogona kufunga kuti rakanakisa chirongwa chekudzidza ichi chingave iyo Linux kernel.

Panzvimbo iyoyo, izvo zviyero zve yazvino Linux kernel shanduro iwo akaomesesa zvekutadza kunzwisiswa nevanhu vazhinji. Kunyanya iyo yakawanda kodhi kune mamwe masisitimu epasi uye madhiraivha aunowana kuti awedzerwa kune iyo kernel pachayo. Izvi zvinogona kukutungamira kuti ufunge kuti mu kernel.org iwe unogona kuwana zvimwe zvekare zvinyorwa zve kernel, senge "nhoroondo" uko kune mamwe "ekare-vhezheni" akadai se Linux 0.01, yekutanga umo kodhi yacho yakanyanya kuderedzwa uye yakapusa kuongorora.

Kernel.org capture

Uye kunyange iyo C kodhi iwe yaunowana muLinux kernel yakanakisa, Ini handikurudzire iyo Linux kernel nekuda kwekuti inowanzo shomeka kutaura pane dzakawanda nguva. Ini handisi kuti ivo vanogadzira vane yakaipa yekutaura mutemo, asi zvinogona kuvhiringidza kune mumwe munhu achangotanga. Saka chengetedza iyo Linux kernel uye LKML yekupedzisira ...

Uye ichokwadi kuti variko mamwe mabhuku akanaka kwazvo uye makosi ekudzidza nezve kernel, ma module uye madhiraivha, asi pamwe haisi nzvimbo yakanaka yekutanga. Mimwe mienzaniso iri (mimwe yacho, saGreg, unogona kurodha mahara, sezvo vaburitswa):

  • Linux Kernel Kubudirira 3rd Edition rakanyorwa naRobert Love.
  • Kunzwisisa Iyo Linux Virtual Memory Manager naMel Goman, kunyangwe iyo yekupedzisira ichinyanya kutarisa nezve kernel memory management.
  • Linux Midziyo Dhirairi 3rd Edition naGreg Kroah-Hartman, kunyange iri yakanangana ne 2.6 kernel, asi ibasa rakakura kuti unzwisise madhiraivha enzira nema module.
  • Linux Kernel muchidimbu ndeimwe yeakakura Greg Kroah-Hartman anokupa iwe yakanyanya kuwoneka yepasirese.

Iwe unogona zvakare kuwana mamwe anonakidza kwazvo mawebhusaiti, kupfuura ako ruzivo uye zvinyorwa iyo iwe yaunogona kuwana pa kernel.org, se:

Imwe yemapurojekiti makuru ayo achiri kudzidza nekushanda sekudzidza iri UNIX yechitanhatu, kodhi yayo inoongororwa nenzira isinganzwisisike mumabhuku akadai se Shumba 'Komendi pane UNIX 6th EditionnaJohn Shumba. Ini ndinozvisiira kwauri seimwewo imwe pfungwa, kunyange ndichiramba ndichikurudzira zvinotevera zvandiri kuzotaura ...

Asi ndinofunga izvozvo sosi yakanakisa yauinayo ndeyekudzidza uye kuongorora iyo MINIX sosi kodhi. Iyo yakapusa sisitimu iyo Linux yakatanga kufuridzirwa asi iyo yakanyatsogadzirirwa kuitisa kudzidza nekudzidza. Kugadzirirwa ramangwana rekushandisa masisitimu ekuvaka kuti vadzidze, mhinduro yainayo inoshamisa kune avo vachangotanga.

Mamwe mashoko - MINIX3

Ikoko iwe unowana yakawanda ruzivo uye zvinyorwa pamusoro peprojekiti. Uye iwe unogona kurodha pasi iyo inoshanda sisitimu pachayo, asi zvakare uine yako yakanaka Wiki uko kune zvekare zvinyorwa zvevagadziri. Asi, sezvo zviri zvekudzidza C uye kuongorora mashandiro ehurongwa, ini ndinokuendesa iwe zvakananga kurodha vhezheni yekutanga ye MINIX 1 kodhi kodhi:

Kodhi kodhi - MINIX1

Semuenzaniso, kana iwe ukaenda ku main faira main.cIwe uchaona kuti kodhi iri pano yakasiyana zvakanyanya kubva pakuiwana kwako muLinux kana muchirongwa chekatorator chandaishandisa semuenzaniso pakutanga kweichi posvo. Mune ino kesi, iwe uchaona kuti huwandu hwemashoko hwakanyanya kuwanda:

MINIX sosi yekodhi

 

Pano, ingangoita mutsetse wese kana chidimbu chega chega chiri comentado. Kugadzira yako kuverenga uye kunzwisisa. Ndinoomerera zvakare, hazvisi zvekuverenga uye kunzwisisa chete, zvakare ndezvekugadzirisa. Gadzira zvako zvigadziriso uye bvunzo, wobva waumbiridza uye uone mhedzisiro. Icho chichava chakanakisa chirongwa tenzi iwe chaunogona kuwana. Ndinokuvimbisa, sezvo ndichigara ndichiudza vadzidzi vangu, kuverenga uye kugadzirisa kodhi ndiyo yakanakisa kirasi yekomputa iwe yauchazove ...

Kwete chete iwe unozogona kuongorora iyo kernel yeanoshanda system, asi zvakare zvimwe zvinobatsira izvo zvinoumba iyo yakazara inoshanda sisitimu uye zvakare kuraira iyo iwe yaunogona kumhanyisa mugoko. Iyo inzira yakanaka yekudzidza kubva "mukati" kuti iyo mirairo senge ls, katsi, cp, grep, echo, nezvimwe, zvaunoita zuva nezuva, zvakare nebasa rakanyatsorondedzerwa rekodhi ...

Raira kodhi kodhi - MINIX1

Chekupedzisira, ndinoziva mukomana akagadzira kernel yakagadzirwa kubva pakutanga. Anonzi Luis uye iwe unogona kuwana purojekiti yake pakero iyi GitHub, mumwe muenzaniso wakanaka wekudzidza wandinokurudzira. Sisitimu yake inonzi India, zviri nyore uye zvakakwana kuwana zivo yekutanga. Ndiani anoziva? Pamwe iwe uchave unotevera kushinga kugadzira kernel ...

Kana iwe uchida kudzidza assembler kana ASM, mutauro unonakidza pamwe neC yekuita chirongwa padanho repasi uye, kunyanya, kune anoshanda masystem ..., kune zvakare zvinonakidza mapurojekiti senge ari kesi ye Hummingbirds, yemahara system yakanyorwa muunganidziri. Kuva muASM, yakanyanya kuomarara, asi zvakare inopa zano rakanaka rekuti michina inoshanda sei padanho repedyo zvine chekuita ne Hardware.

Dzidziso: Dhinda kodhi kodhi kuti uidzidze pabepa

PDF ine kodhi yakajeka kodhi

Kana iwe uri mumwe weavo vasingade kushandisa maawa pamberi pechiso uye uchitarisa pairi, pamwe unofarira bepa. Ndiri kuzokuratidza diki dzidziso yekuti ungadhinda sei ese aya masosi kodhi atakataura nezvayo kana ayo aunoda kuongorora. Saka unogona iva nePDF ine syntax yakakwenenzverwa yakagadzirira kupurinda pane yako purinda uye uverenge pabepa, kwaunogona kugadzira zvirevo zvako uye nezvimwe.

Kuti uite izvi, chinhu chekutanga chichava gadza mapakeji anodikanwa mune yedu distro:

 

sudo apt-get install texlive-latex-extra latex-xcolor textlive-latex-recommended

 

 

Kana tangove nemafaira aya, isu tinoshandisa LATEX Kuti tishandure kodhi yekodhi kuti ive PDF, uye nekuda kweizvi isu tinofanirwa kuchengetedza chinyorwa ichi, kuchipa mvumo yekuita uye kuitisa muBhash:

#!/usr/bin/env bash

tex_file=$(mktemp) ## Random text file name

cat<<EOF >$tex_file   ## Print the text file header
\documentclass{article}
\usepackage{listings}
\usepackage[usenames,dvipsnames]{color}  %% Allow color names
\lstdefinestyle{customasm}{
  belowcaptionskip=1\baselineskip,
  xleftmargin=\parindent,
  language=C++,   %% Change this to whatever you write in
  breaklines=true, %% Wrap long lines
  basicstyle=\footnotesize\ttfamily,
  commentstyle=\itshape\color{Gray},
  stringstyle=\color{Black},
  keywordstyle=\bfseries\color{OliveGreen},
  identifierstyle=\color{blue},
  xleftmargin=-8em,
}        
\usepackage[colorlinks=true,linkcolor=blue]{hyperref} 
\begin{document}
\tableofcontents

EOF

find . -type f ! -regex ".*/\..*" ! -name ".*" ! -name "*~" ! -name 'src2pdf'|
sed 's/^\..//' |                 ## Change ./foo/bar.src to foo/bar.src

while read  i; do                ## Loop through each file
    name=${i//_/\\_}             ## escape underscores
    echo "\newpage" >> $tex_file   ## start each section on a new page
    echo "\section{$i}" >> $tex_file  ## Create a section for each filename

   ## This command will include the file in the PDF
    echo "\lstinputlisting[style=customasm]{$i}" >>$tex_file
done &&
echo "\end{document}" >> $tex_file &&
pdflatex $tex_file -output-directory . && 
pdflatex $tex_file -output-directory .  ## This needs to be run twice ## for the TOC to be generated  </pre><pre>

Mushure mekuichengeta kune faira riine zita pdf.sh, unogona kuzvipa mvumo uye kuzviita nenzira iri nyore:

chmod +x pdf.sh
./pdf.sh

Uye mhedzisiro yacho ichave iyo PDF ine zvinyorwa zvakakwidziridzwa muvara kuti uverenge zviri nani kwemafaira kodhi yekodhi yedhairekitori riripo. Zita regwaro rePDF richava zvese.pdf. Iye zvino zvichave zvakagadzirira iwe kuti uzviise mumutsetse wako wekudhinda kuti uve nazvo pabepa.

Nenzira, iro chete dambudziko nderekuti iyo sosi kodhi mafaera Dhairekitori iyo iwe yaunomhanyisa iyi script ine nzvimbo mumazita avo haishande neiyi script. Saka kana paine chero iwe unogona kugadzirisa zita ravo kana kushandura script kuti uvatsigire ...

Usakanganwa kusiya zvaunotaura, Ndichave ndichifara kupindura chero mibvunzo yauinayo nezvazvo, kana kuteerera chero mhinduro yaunayo yekuvandudza iyo posvo. Uye ndinovimba yakashanda segwara rekutangisa iwe munyika ino ...


Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Makomendi gumi, siya zvako

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa. Raida minda anozivikanwa ne *

*

*

  1. Inotarisira data: AB Internet Networks 2008 SL
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako

  1.   slam akadaro

    Kwakanaka kwazvo kutumira… !!!
    Ini ndinongova nedambudziko nechinyorwa, chinovhotera zvikanganiso pamutsetse wechishanu.

  2.   Javier akadaro

    Mhoro, husiku hwakanaka kuno kuMexico, zvingave zvakanaka kuti iwe urambe uchinyora kuburikidza nesvikiro uye, kana zvichibvira, ramba uchizadza neruzivo. Kune rimwe divi, ndinokutendai nekupa nguva yenyu neruzivo zvatakasiirwa hafu. Nyaya yangu yandaive nayo ndeyekuti ndakasiya basa rangu nekuda kwematambudziko izvozvi ndinoshanda kuti ndizvitsigire. Zvishoma nezvishoma ndiri kunhonga zvinhu mupfungwa iyi, Chaizvoizvo Kutenda.

  3.   ngirozi martinez akadaro

    Ini ndinowana sei ruzivo rwese maererano nezvechirongwa

  4.   Isma risina rudo akadaro

    Dambudziko nemutsara wechishanu pamwe (nekuti ini handisati ndambozviedza xd) imo nekuti yakanyorwa seizvi

    kati < $ tex_file ## Dhinda iyo faira faira musoro

    pazvinofanira kunge zvakaita seizvi:

    kati <$ tex_file ## Dhinda iyo faira faira musoro

    Kana saka ndinofungidzira: U ...

    Thanks.

  5.   Isma risina rudo akadaro

    Ah gehena panguva ino akazviita chaizvo>: v

  6.   Gregorio ros akadaro

    Makorokoto pachinyorwa ichi, ndakachida! Mira zvirongwa apfuura…. xD angangoita makore makumi matatu, kasingaverengeki nguva ndakafunga kuitora zvakare uye nekuda kwekushayikwa kwenguva uye kunyanya KUSVIRA ndinogara ndichizvidzosera. Ini ndinobvuma kuti zvinyorwa izvo zviripo izvozvi zvinonakidza, zvinosuwisa kuti zvizhinji zvacho zviri muChirungu, ndinoziva kuti iye zvino munhu wese anoda kuzvinzwisisa, asi ruzivo rwangu rwunogumira pane mashoma mazwi anodarika gumi nemaviri anoshandiswa muchirongwa. Pane here dzidziso pane kernell muSpanish?. Ini handivimbise kutangazve chirongwa, ndakachisiya kakawanda kuti nditende kuti ndinogona kuzviita izvozvi, asi kana paine chimwe chinhu chandisina kumborasa, kwaive kuda kuziva. Ndatenda nechinyorwa uye nezvakanakisa.