[{"data":1,"prerenderedAt":335},["ShallowReactive",2],{"project-30991235":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":42,"post_text":45,"what":46,"said":90,"maker_in_thread":179,"shape":188,"grid":192,"attempts":295,"same_week":296,"maker_shows":32,"maker_hidden":327,"reader_version":328,"card":329},"30991235","howto-wasm-minimal","How to compile C\u002FC++ for WASM, pure Clang, no libs, no framework","title","Show HN: How to compile C\u002FC++ for WASM, pure Clang, no libs, no framework","https:\u002F\u002Fgithub.com\u002Fern0\u002Fhowto-wasm-minimal","github.com","ern0",1649694900,2022,217,42,252,2570,10,"notable","dev_tools","wasm build tutorial","other",[24,25,26,27,28],"webassembly","clang","c++ wasm","emscripten alternative","wasm without framework","curious",-0.179,{"positive":32,"neutral":33,"mixed":34,"critical":35},1,7,0,4,12,{"execution":38,"performance":40,"idea":41},{"positive":34,"critical":39},2,{"positive":34,"critical":32},{"positive":32,"critical":34},[43,34,34,34,34,34,34,34,32,34,34,43,34,32,34,43,34,34,43,34,43,34,34,34,32,34,34,43,34,34,34,34,34,34,34,34,32,43,34,44],3,5,"A little help for programmers, who wants to run C\u002FC++ code in the browser.\n\n(This is my second attempt to show it, first time I got banned bcoz of my personal page domain, I don't really understand it why is is suspicious.)",{"problem":47,"audience":53,"pricing":57,"motivation":58,"time_to_build":57,"stack":62,"openness":88,"stage":89,"team_size":89},{"value":48,"source":49,"evidence":50},"Compiling C\u002FC++ to run in the browser without frameworks or libraries.","maker",[51],{"id":52},"post",{"value":54,"source":49,"evidence":55},"Programmers who want to run C\u002FC++ code in the browser.",[56],{"id":52},null,{"value":59,"source":49,"evidence":60},"To help programmers run C\u002FC++ in the browser.",[61],{"id":52},[63,71,80,84],{"value":64,"source":65,"evidence":66},"C","commenter",[67],{"id":68,"by":69,"text":70},"30994865","pulse7","Is there a similar example for C?",{"value":72,"source":49,"evidence":73},"C++",[74,77],{"id":75,"by":11,"text":76},"31012660","I know it (see: https:\u002F\u002Fgithub.com\u002Fern0\u002Fkolorwheel.js ), but I did not wanted use floats.",{"id":78,"by":11,"text":79},"31012711","Just rename the file and remove extern \"C\" stuff :). It started as C, but then I switched to CPP, to see, can I export simple symbol names, not mangled ones C++ produces. Anyway,…",{"value":81,"source":49,"evidence":82},"Clang",[83],{"id":52},{"value":85,"source":49,"evidence":86},"WebAssembly",[87],{"id":52},"open_source","unknown",{"praise":91,"objections":103,"requests":122,"questions":137,"alternatives":149},[92],{"value":93,"source":65,"evidence":94},"Good resource for compiling without Emscripten",[95,99],{"id":96,"by":97,"text":98},"30993140","bla3","These are also good resources on using wasm without dependencies: https:\u002F\u002Fdepth-first.com\u002Farticles\u002F2019\u002F10\u002F16\u002Fcompiling-c-to-webassembly-and-running-it-without-emscripten\u002F…",{"id":100,"by":101,"text":102},"30993606","petters","See also my example I put together some time ago: https:\u002F\u002Fgithub.com\u002FPetterS\u002Fclang-wasm At the time, I could not find something like this online. It's fun to write your own…",[104,115],{"value":105,"source":65,"evidence":106},"Gray conversion uses simple average instead of luminance weights",[107,111],{"id":108,"by":109,"text":110},"30992742","dosshell","directly when reading this code I cannot help myself but to get into review-mode. It is an awesome example, which i will probably use myself one day. However... inc.cpp:27 Gray…",{"id":112,"by":113,"text":114},"30993204","syrusakbary","For future readers, this is the code that is being referred: https:\u002F\u002Fgithub.com\u002Fern0\u002Fhowto-wasm-minimal\u002Fblob\u002Fmaster\u002Finc.cpp#L31-L35 It should be: ``` uint32_t gray = 0.299 *…",{"value":116,"source":65,"evidence":117},"Declaring memory as uint8_t instead of array is non-idiomatic",[118],{"id":119,"by":120,"text":121},"30993096","moefh","This is really cool! I never looked into WASM before, I'm really happy to see it's not that difficult to build a simple example like this. One thing that's bothering me about…",[123,130],{"value":124,"source":65,"evidence":125},"Zero-copy canvas access from C code",[126],{"id":127,"by":128,"text":129},"30994264","drfuchs","(Obligatory:) Neat! Still, a lot of copying bits around, and more JS than one might hope for. Could you send a pointer to canvas into the C code and operate on it in a direct,…",{"value":131,"source":65,"evidence":132},"Support for compiling third-party C\u002FC++ libraries",[133],{"id":134,"by":135,"text":136},"30992158","melony","This looks good! In my experience the hardest part for compiling WebAssembly is third party dependencies. Getting arbitrary libraries to build can be rather challenging.",[138,145],{"value":139,"source":65,"evidence":140},"How to compile Rust code to WASM without wasm-pack",[141],{"id":142,"by":143,"text":144},"30992144","gspr","Very cool! I've been desperately looking for something similar for Rust. I'm too old for all these magic frameworks and \"deployers\" :-) I have some Rust code, possibly linking in…",{"value":146,"source":65,"evidence":147},"Is there a similar example for plain C",[148],{"id":68,"by":69,"text":70},[150,158,165,172],{"value":151,"source":65,"evidence":152},"Emscripten",[153,157],{"id":154,"by":155,"text":156},"30993643","jstimpfle","Pedantically, it might even be undefined behaviour (not sure, maybe a point of contention, similar to container_of macro). It's unlikely to cause problems, but the way you…",{"id":100,"by":101,"text":102},{"value":159,"source":65,"evidence":160},"wasm-pack (Rust)",[161],{"id":162,"by":163,"text":164},"30994809","aquova","I made some emulators in Rust as a learning project during the start of the pandemic, and ran into the exact same issue when I wanted to make a wasm version to run in a browser.…",{"value":166,"source":65,"evidence":167},"wajic",[168],{"id":169,"by":170,"text":171},"30999652","flohofwoe","Since I haven't seen it mentioned in the comments yet, here's another interesting project in the general area of \"WASM without Emscripten\": https:\u002F\u002Fgithub.com\u002Fschellingb\u002Fwajic…",{"value":173,"source":65,"evidence":174},"WebAssembly Studio",[175],{"id":176,"by":177,"text":178},"30992242","randomsilence","Do you know https:\u002F\u002Fwebassembly-studio.kamenokosoft.com\u002F ? I don't know if it compiles in the browser or on a server.",{"comments":44,"answered":32,"key":180},[181,182,185],{"id":75,"text":76},{"id":183,"text":184},"31012668","thx, fixed (hopefully)",{"id":186,"text":187},"31012724","Especially - ofcoz' maybe I'm wrong -, that there're not too many C\u002FC++ libs for WASM, always Rust comes up.",{"commenters":189,"max_depth":44,"maker_replies":44,"first_comment_mins":190,"lifespan_hours":191},28,32,41,[193,195,197,200,201,202,204,208,210,212,216,219,220,222,225,228,231,233,237,239,241,242,246,248,250,251,254,257,258,261,264,266,267,269,271,274,277,280,285,287,290,291],[119,34,43,194,120,34],"project\u002Fneutral\u002Fexecution",[154,34,34,196,155,34],"commenter\u002Fneutral\u002Fexecution",[198,32,34,199,163,34],"30994928","other\u002Fneutral\u002Fnone",[142,39,34,199,143,34],[162,39,34,199,163,34],[203,43,34,199,113,34],"30992397",[205,43,34,206,207,34],"30992562","commenter\u002Fneutral\u002Fnone","hobo_mark",[209,43,34,206,113,34],"30992986",[108,35,32,211,109,34],"project\u002Fcritical\u002Fexecution",[213,35,34,214,215,34],"30992954","commenter\u002Fcritical\u002Fnone","Datagenerator",[217,35,34,206,218,34],"30993073","jhgb",[112,35,43,194,113,34],[75,35,34,221,11,32],"maker\u002Fneutral\u002Fexecution",[223,35,32,211,224,34],"30993614","Asooka",[226,35,34,206,227,34],"30997039","astrange",[229,44,43,221,230,34],"30991785","eatonphil",[183,44,34,232,11,32],"maker\u002Fneutral\u002Fnone",[234,235,34,199,236,34],"30992974",6,"0x20cowboy",[134,33,43,238,135,34],"project\u002Fneutral\u002Fnone",[240,33,34,199,218,34],"30992388",[186,33,34,238,11,32],[243,244,43,194,245,34],"30992038",8,"david2ndaccount",[247,244,34,221,11,32],"31012691",[100,249,34,199,101,34],9,[169,18,34,199,170,34],[127,252,32,253,128,34],11,"project\u002Fcritical\u002Fperformance",[255,252,34,206,256,34],"30996818","brrrrrm",[96,36,34,199,97,34],[259,260,43,238,207,34],"30991853",13,[262,260,34,199,263,34],"30992029","mbrock",[265,260,34,199,207,34],"30992225",[176,260,34,199,177,34],[268,260,34,199,207,34],"30992311",[270,260,34,199,177,34],"30992592",[272,260,34,273,207,34],"30992692","other\u002Fneutral\u002Fprivacy",[275,260,34,199,276,34],"30995901","bialpio",[278,260,34,199,279,34],"31001326","jansommer",[281,282,32,283,284,34],"30992200",14,"project\u002Fcritical\u002Fnone","eeegnu",[68,286,43,238,69,34],15,[288,286,34,199,289,34],"30995074","nhatcher",[78,286,34,221,11,32],[292,293,44,294,218,34],"30992375",16,"project\u002Fpositive\u002Fidea",[],[297,302,307,312,317,322],{"id":298,"name":299,"points":300,"category":301},"30946792","Redditle.com",448,"web_saas",{"id":303,"name":304,"points":305,"category":306},"30970911","Explordle",390,"learning_science",{"id":308,"name":309,"points":310,"category":311},"30956775","Eight Colors",368,"games",{"id":313,"name":314,"points":315,"category":316},"31002171","indieblog.page",241,"productivity",{"id":318,"name":319,"points":320,"category":321},"30992587","Multiplayer",221,"infrastructure",{"id":323,"name":324,"points":325,"category":326},"31013326","Half Loaf Near Me",196,"consumer_social",false,"v2",{"id":330,"name":5,"line":6,"ai":327,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":331,"top":18,"kw":332,"maker":11,"domain":10,"tier":19,"attempts":34,"strip":333,"url":9,"mix":334,"praise":93,"objection":105,"sub":21},30991235,-0.18,[24,25,26,27,28],"3000000010030103003030001003000000001305",[32,33,34,35],1794036619085]