C Printf Format Codes Binary Options

Best Practices for A C Programmer

Hi all,
Long time C programmer here, primarily working in the embedded industry (particularly involving safety-critical code). I've been a lurker on this sub for a while but I'm hoping to ask some questions regarding best practices. I've been trying to start using c++ on a lot of my work - particularly taking advantage of some of the code-reuse and power of C++ (particularly constexpr, some loose template programming, stronger type checking, RAII etc).
I would consider myself maybe an 8/10 C programmer but I would conservatively maybe rate myself as 3/10 in C++ (with 1/10 meaning the absolute minmum ability to write, google syntax errata, diagnose, and debug a program). Perhaps I should preface the post that I am more than aware that C is by no means a subset of C++ and there are many language constructs permitted in one that are not in the other.
In any case, I was hoping to get a few answers regarding best practices for c++. Keep in mind that the typical target device I work with does not have a heap of any sort and so a lot of the features that constitute "modern" C++ (non-initialization use of dynamic memory, STL meta-programming, hash-maps, lambdas (as I currently understand them) are a big no-no in terms of passing safety review.

When do I overload operators inside a class as opposed to outisde?

... And what are the arguments foagainst each paradigm? See below:
/* Overload example 1 (overloaded inside class) */ class myclass { private: unsigned int a; unsigned int b; public: myclass(void); unsigned int get_a(void) const; bool operator==(const myclass &rhs); }; bool myclass::operator==(const myclass &rhs) { if (this == &rhs) { return true; } else { if (this->a == rhs.a && this->b == rhs.b) { return true; } } return false; } 
As opposed to this:
/* Overload example 2 (overloaded outside of class) */ class CD { private: unsigned int c; unsigned int d; public: CD(unsigned int _c, unsigned int _d) : d(_d), c(_c) {}; /* CTOR */ unsigned int get_c(void) const; /* trival getters */ unsigned int get_d(void) const; /* trival getters */ }; /* In this implementation, If I don't make the getters (get_c, get_d) constant, * it won't compile despite their access specifiers being public. * * It seems like the const keyword in C++ really should be interpretted as * "read-only AND no side effects" rather than just read only as in C. * But my current understanding may just be flawed... * * My confusion is as follows: The function args are constant references * so why do I have to promise that the function methods have no side-effects on * the private object members? Is this something specific to the == operator? */ bool operator==(const CD & lhs, const CD & rhs) { if(&lhs == &rhs) return true; else if((lhs.get_c() == rhs.get_c()) && (lhs.get_d() == rhs.get_d())) return true; return false; } 
When should I use the example 1 style over the example 2 style? What are the pros and cons of 1 vs 2?

What's the deal with const member functions?

This is more of a subtle confusion but it seems like in C++ the const keyword means different things base on the context in which it is used. I'm trying to develop a relatively nuanced understanding of what's happening under the hood and I most certainly have misunderstood many language features, especially because C++ has likely changed greatly in the last ~6-8 years.

When should I use enum classes versus plain old enum?

To be honest I'm not entirely certain I fully understand the implications of using enum versus enum class in C++.
This is made more confusing by the fact that there are subtle differences between the way C and C++ treat or permit various language constructs (const, enum, typedef, struct, void*, pointer aliasing, type puning, tentative declarations).
In C, enums decay to integer values at compile time. But in C++, the way I currently understand it, enums are their own type. Thus, in C, the following code would be valid, but a C++ compiler would generate a warning (or an error, haven't actually tested it)
/* Example 3: (enums : Valid in C, invalid in C++ ) */ enum COLOR { RED, BLUE, GREY }; enum PET { CAT, DOG, FROG }; /* This is compatible with a C-style enum conception but not C++ */ enum SHAPE { BALL = RED, /* In C, these work because int = int is valid */ CUBE = DOG, }; 
If my understanding is indeed the case, do enums have an implicit namespace (language construct, not the C++ keyword) as in C? As an add-on to that, in C++, you can also declare enums as a sort of inherited type (below). What am I supposed to make of this? Should I just be using it to reduce code size when possible (similar to gcc option -fuse-packed-enums)? Since most processors are word based, would it be more performant to use the processor's word type than the syntax specified above?
/* Example 4: (Purely C++ style enums, use of enum class/ enum struct) */ /* C++ permits forward enum declaration with type specified */ enum FRUIT : int; enum VEGGIE : short; enum FRUIT /* As I understand it, these are ints */ { APPLE, ORANGE, }; enum VEGGIE /* As I understand it, these are shorts */ { CARROT, TURNIP, }; 
Complicating things even further, I've also seen the following syntax:
/* What the heck is an enum class anyway? When should I use them */ enum class THING { THING1, THING2, THING3 }; /* And if classes and structs are interchangable (minus assumptions * about default access specifiers), what does that mean for * the following definition? */ enum struct FOO /* Is this even valid syntax? */ { FOO1, FOO2, FOO3 }; 
Given that enumerated types greatly improve code readability, I've been trying to wrap my head around all this. When should I be using the various language constructs? Are there any pitfalls in a given method?

When to use POD structs (a-la C style) versus a class implementation?

If I had to take a stab at answering this question, my intuition would be to use POD structs for passing aggregate types (as in function arguments) and using classes for interface abstractions / object abstractions as in the example below:
struct aggregate { unsigned int related_stuff1; unsigned int related_stuff2; char name_of_the_related_stuff[20]; }; class abstraction { private: unsigned int private_member1; unsigned int private_member2; protected: unsigned int stuff_for_child_classes; public: /* big 3 */ abstraction(void); abstraction(const abstraction &other); ~abstraction(void); /* COPY semantic ( I have a better grasp on this abstraction than MOVE) */ abstraction &operator=(const abstraction &rhs); /* MOVE semantic (subtle semantics of which I don't full grasp yet) */ abstraction &operator=(abstraction &&rhs); /* * I've seen implentations of this that use a copy + swap design pattern * but that relies on std::move and I realllllly don't get what is * happening under the hood in std::move */ abstraction &operator=(abstraction rhs); void do_some_stuff(void); /* member function */ }; 
Is there an accepted best practice for thsi or is it entirely preference? Are there arguments for only using classes? What about vtables (where byte-wise alignment such as device register overlays and I have to guarantee placement of precise members)

Is there a best practice for integrating C code?

Typically (and up to this point), I've just done the following:
/* Example 5 : Linking a C library */ /* Disable name-mangling, and then give the C++ linker / * toolchain the compiled * binaries */ #ifdef __cplusplus extern "C" { #endif /* C linkage */ #include "device_driver_header_or_a_c_library.h" #ifdef __cplusplus } #endif /* C linkage */ /* C++ code goes here */ 
As far as I know, this is the only way to prevent the C++ compiler from generating different object symbols than those in the C header file. Again, this may just be ignorance of C++ standards on my part.

What is the proper way to selectively incorporate RTTI without code size bloat?

Is there even a way? I'm relatively fluent in CMake but I guess the underlying question is if binaries that incorporate RTTI are compatible with those that dont (and the pitfalls that may ensue when mixing the two).

What about compile time string formatting?

One of my biggest gripes about C (particularly regarding string manipulation) frequently (especially on embedded targets) variadic arguments get handled at runtime. This makes string manipulation via the C standard library (printf-style format strings) uncomputable at compile time in C.
This is sadly the case even when the ranges and values of paramers and formatting outputs is entirely known beforehand. C++ template programming seems to be a big thing in "modern" C++ and I've seen a few projects on this sub that use the turing-completeness of the template system to do some crazy things at compile time. Is there a way to bypass this ABI limitation using C++ features like constexpr, templates, and lambdas? My (somewhat pessimistic) suspicion is that since the generated assembly must be ABI-compliant this isn't possible. Is there a way around this? What about the std::format stuff I've been seeing on this sub periodically?

Is there a standard practice for namespaces and when to start incorporating them?

Is it from the start? Is it when the boundaries of a module become clearly defined? Or is it just personal preference / based on project scale and modularity?
If I had to make a guess it would be at the point that you get a "build group" for a project (group of source files that should be compiled together) as that would loosely define the boundaries of a series of abstractions APIs you may provide to other parts of a project.
--EDIT-- markdown formatting
submitted by aWildElectron to cpp [link] [comments]

Nothing to see here! pls scroll to next post!

debug.cpp TesterHook.cpp entityidxarray.cpp graph.cpp graphnode.cpp modAI_Memory.cpp aAI_CommsInstructions.cpp aAI_EntityInterface.cpp cAI_Action.cpp cAI_AdminManager.cpp cAI_Agent.cpp cAI_CommsModule.cpp cAI_CommsPrefix.cpp cAI_CommsPrep.cpp cAI_EntityGame.cpp cAI_EntityPlayer.cpp cAI_TransitionData.cpp cAI_Variables.cpp modAI_Audio.cpp modAI_Communication.cpp modAI_Identifier.cpp modAI_Interaction.cpp modAI_Interface.cpp modAI_Senses.cpp modAI_Synchronisation.cpp aAI_PerformTask.cpp cAI_ActionManager.cpp cAI_AnimInterface.cpp cAI_LowLevelInterface.cpp cAI_PerformanceManager.cpp cAI_PerformancePhase.cpp cAI_PerformTaskAction.cpp cAI_PerformTaskAnim.cpp cAI_PerformTaskAudio.cpp cAI_SpeechInterface.cpp aAI_Controller.cpp aAI_ControllerCombat.cpp aAI_Coordinator.cpp aAI_EntityIDArray.cpp aAI_Objective.cpp cAI_ControllerBoundary.cpp cAI_ControllerCamp.cpp cAI_ControllerCombatBlind.cpp cAI_ControllerCombatCover.cpp cAI_ControllerCombatMelee.cpp cAI_ControllerCoverSeek.cpp cAI_ControllerFollow.cpp cAI_ControllerFollowThrough.cpp cAI_ControllerGoto.cpp cAI_ControllerGotoGunfire.cpp cAI_ControllerGuard.cpp cAI_ControllerHide.cpp cAI_ControllerIdle.cpp cAI_ControllerOrbit.cpp cAI_ControllerSearch.cpp cAI_ControllerStop.cpp cAI_CoordinateBoundary.cpp cAI_CoordinateGenericAction.cpp cAI_CoordinateGenericCombat.cpp cAI_CoordinateGuard.cpp cAI_CoordinateIdle.cpp cAI_CoordinateInvestigate.cpp cAI_CoordinateKillEnemy.cpp cAI_CoordinateSearch.cpp cAI_Goal.cpp cAI_GoalDefinition.cpp cAI_IdleActions.cpp cAI_ObjectiveBeBuddy.cpp cAI_ObjectiveHuntEnemy.cpp cAI_ObjectiveIdle.cpp cAI_ObjectiveScriptedAction.cpp cAI_Pack.cpp cAI_Subpack.cpp cAI_HearingSense.cpp cAI_SensesData.cpp cAI_SensingPhase.cpp cAI_VisionSense.cpp meleeTraits.cpp traits.cpp acts.cpp atomicActs.cpp combatUtil.cpp coverActs.cpp gunActBase.cpp meleeActs.cpp pedBodyAnimFSM.cpp pedTorsoAnimFSM.cpp compDriver.cpp weaponController.cpp formation.cpp motion.cpp navigation.cpp navPoint.cpp navTactics.cpp pointTracker.cpp squad.cpp pedSpace.cpp gunPerception.cpp itemPerception.cpp meleeCombatPerception.cpp pedRelationshipPerception.cpp selfPerception.cpp Senses.cpp Vision.cpp AnimBlendAssociation.cpp AnimBlendClumpData.cpp AnimBlendHierarchy.cpp AnimBlendNode.cpp AnimBlendSequence.cpp AnimHierarchy.cpp AnimManager.cpp Compressed.cpp EntityAnim.cpp App.cpp GameTime.cpp AmbientTransitionManager.cpp AudioAnim.cpp audiobloodfx.cpp AudioCollision.cpp audiolog.cpp audioman.cpp AudioMisc.cpp AudioScripted.cpp AudioTextMap.cpp CriAdxStream.cpp CriAixStream.cpp CriInterface.cpp dmaudio.cpp music.cpp SampleManagerChannelFunctions.cpp sampman.cpp ScriptedStream.cpp SpeechManager.cpp VolumeFader.cpp AgeSupport.cpp manager.cpp sfx.cpp system_wii.cpp BufferedSoundWii.cpp CRC.cpp SectorReadables.cpp ColAABox.cpp ColArch.cpp ColData.cpp ColFrustum.cpp ColLine.cpp Collision.cpp ColModelLine.cpp ColModelPoint.cpp ColModelSphere.cpp ColModelTri.cpp ColPrim.cpp ColSphere.cpp ColTri.cpp ContactInfo.cpp ColCylinder.cpp ColModelCylinder.cpp console.cpp skel.cpp wiiplatform.cpp CollectableEffect.cpp CreationManager.cpp Entity.cpp EntityManager.cpp OddEntity.cpp TypeData.cpp Character.cpp ped.cpp pedstates.cpp attackdirectiondata.cpp attackdirectionlookup.cpp pedcombatlookups.cpp pedspinecontrol.cpp pushporter.cpp Climb.cpp Crawl.cpp Crouch.cpp Detector.cpp Dive.cpp Jump.cpp JumpPredictor.cpp autoped.cpp Hunter.cpp Leader.cpp PedHead.cpp delayedHunterSpawn.cpp RsvGoreEffectForExecutions.cpp CameraData.cpp collectable.cpp conveyor.cpp door.cpp EntityLight.cpp Lift.cpp mover.cpp ShotEntity.cpp slidedoor.cpp switch.cpp Trigger.cpp Useable.cpp EntitySound.cpp EnvironmentalExecution.cpp Helicopter.cpp ShadowPlane.cpp FileHandler.cpp FileNames.cpp LoadSave.cpp eyelayerinset.cpp Frontend.cpp FrontendMenu.cpp GameInfo.cpp GameInventory.cpp GameMap.cpp randomuvanimator.cpp tvlayerinset.cpp confirmnewgamepage.cpp inventorystatussettings.cpp layeredbackground.cpp layeredpage.cpp pageeffects.cpp randomoverlay.cpp screenanim.cpp screeneffectsmanager.cpp startpage.cpp texanimator.cpp weaponslotcolours.cpp weaponswapper.cpp weaponswappersettings.cpp backgroundPicAnim.cpp bar.cpp confirmingameQuitPage.cpp ContextButtonDisplay.cpp controllerPage.cpp defaultSettingsPage.cpp ExecutionBox.cpp ExecutionFrame.cpp FlexText.cpp GoalFlexText.cpp hud.cpp hudItem.cpp ingameMainPage.cpp InventorySelector.cpp inventoryStatus.cpp item.cpp LevelNameFlexText.cpp LoadProgressScreen.cpp menu.cpp newGameBrightnessPage.cpp page.cpp radar.cpp saveGamesPage.cpp sceneselectionPage.cpp screen.cpp startLanguageSelectionPage.cpp textures.cpp cGEN_String.cpp cGEN_Timer.cpp gGEN_Globals.cpp gGEN_StandardFunctions.cpp modGEN_Housekeeping.cpp modGEN_Memory.cpp stats.cpp aGEN_Array.cpp cGEN_CharArray.cpp cDBG_DebugFile.cpp modDBG_LowLevelDebug.cpp aGEN_Memory.cpp modGEN_MemoryReporting.cpp rwcore.cpp TextUtils.cpp UniCodeUtils.cpp MhGlobalData.cpp MhLoadSave_Wii.cpp MhPeripherals_Wii.cpp Pad_Wii.cpp WiiLoadSave.cpp CheatHandler.cpp InputManager.cpp WiiAccelerometer.cpp WiiGesture.cpp ActionMapping.cpp KeyCode.cpp Inventory.cpp fx.cpp fxEmitter.cpp fxInfo.cpp fxInterp.cpp fxKeyGen.cpp fxList.cpp fxManager.cpp fxPrim.cpp fxSystem.cpp fxUtils.cpp MHtoFXinterface.cpp Maths.cpp Matrix.cpp Quaternion.cpp Vector.cpp MemManager.cpp PoolAllocationManager.cpp PoolAllocator.cpp CutsceneCamera.cpp EntityFadeController.cpp SimpleLinearAllocator.cpp Cylinder.cpp FrisbeeArm.cpp CriAfsPartition.cpp CriDataStream.cpp DataStreamManager.cpp Portal.cpp StreamedLevelSector.cpp StreamedLevelSectorCore.cpp StreamedLevelSectorManager.cpp StreamedAnimation.cpp StreamedAnimationManager.cpp TexturePool.cpp TexturePoolGroup.cpp TexturePoolManager.cpp AiHelpers.cpp EntityAttrReader.cpp EntityAttrWriter.cpp EntityTextureRenderer.cpp EnvironmentID.cpp PathSearch.cpp RsvDebuggingInfoForUseables.cpp RsvTvpChecker.cpp StringHashing.cpp OverlayMgr.cpp RwRGBA_Globals.cpp ScreenStringsOverlay.cpp TextOverlay.cpp Physics.cpp collisionFrame.cpp camglobals.cpp Crosshair.cpp ExecutionTutorial.cpp handicam.cpp ImpactDamageMap.cpp player.cpp playercam.cpp PLayerLimits.cpp playerstates.cpp WiiExecutionMap.cpp WiiQuickTimeMoment.cpp grenade.cpp responder.cpp Atomic.cpp Camera.cpp CharacterDamageManager.cpp CharacterDamageMap.cpp Clump.cpp ClumpDict.cpp clumplist.cpp collisionmaterial.cpp EntityShadow.cpp EntityShadowManager.cpp Frame.cpp Geometry.cpp Light.cpp lights.cpp material.cpp materiallist.cpp scene.cpp sceneData.cpp skin.cpp spline.cpp texdictionary.cpp texture.cpp tvp.cpp utils.cpp uvanimator.cpp World.cpp WorldSector.cpp CutScene.cpp CutScenePlayed.cpp EntityShadowFader.cpp MaterialMapper.cpp lit_environmentmap.cpp lit_singletexture.cpp lit_singletexture_uvanim.cpp lit_texreconfig.cpp unlit_32indtexture.cpp unlit_notexture.cpp unlit_singletexture.cpp entityData.cpp LoadedScript.cpp ScriptCaseFloat.cpp ScriptCaseGame.cpp ScriptCaseGame2.cpp ScriptCaseGame3.cpp ScriptCaseGameRsv.cpp ScriptCaseInternals.cpp ScriptCaseStandard.cpp ScriptCaseStrings.cpp ScriptLoader.cpp ScriptManager.cpp ScriptVM.cpp BreakingGlass.cpp clouds.cpp Decal.cpp dualtexture.cpp fogpatch.cpp FXMode.cpp LightFX.cpp ParticleEffect.cpp ParticleModel.cpp rats.cpp Renderbuffer.cpp rubbish.cpp SFXManager.cpp StreakEffect.cpp TrailEffect.cpp Weather.cpp jitter.cpp lipsync.cpp spotlight.cpp spotlightcone.cpp throwgraphic.cpp OverbrightEffect.cpp VideoScreenEffect.cpp Str.cpp Timer.cpp Shot.cpp Weapon.cpp WeaponManager.cpp colramp.cpp Gu.cpp GuProfiler.cpp main.cpp renderer.cpp rslengine.cpp shadermgr.cpp vectorASM.cpp volatilemem.cpp WiiGeometry.cpp WiiShader.cpp WorldCollision.cpp actor.c control.c displayObject.c dmabuffer.cpp fileCache.c geoPalette.c GQRSetup.c List.c normalTable.c SKNControl.c SKNMath.c string.c texPalette.c Tree.c HomeButtonMenu.cpp display.cpp binkfunctions.cpp binkplayer.cpp wiitextures.c adler32.c infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c zutil.c binkwii.c binkread.c wiiax.c wiifile.c binkacd.c radcb.c expand.c popmal.c radmem.c fft.c dct.c bitplane.c ai.c arc.c AX.c AXAlloc.c AXAux.c AXCL.c AXOut.c AXSPB.c AXVPB.c AXProf.c AXComp.c DSPCode.c AXFXReverbHi.c AXFXReverbHiDpl2.c AXFXReverbHiExp.c AXFXReverbHiExpDpl2.c AXFXReverbStd.c AXFXReverbStdExp.c AXFXHooks.c PPCArch.c gki_buffer.c gki_time.c gki_ppc.c hcisu_h2.c uusb_ppc.c bta_dm_cfg.c bta_hh_cfg.c bta_sys_cfg.c bte_hcisu.c bte_init.c bte_logmsg.c bte_main.c btu_task1.c bd.c bta_sys_conn.c bta_sys_main.c ptim.c utl.c bta_dm_act.c bta_dm_api.c bta_dm_main.c bta_dm_pm.c bta_hh_act.c bta_hh_api.c bta_hh_main.c bta_hh_utils.c btm_acl.c btm_dev.c btm_devctl.c btm_discovery.c btm_inq.c btm_main.c btm_pm.c btm_sco.c btm_sec.c btu_hcif.c btu_init.c wbt_ext.c gap_api.c gap_conn.c gap_utils.c hcicmds.c hidd_api.c hidd_conn.c hidd_mgmt.c hidd_pm.c hidh_api.c hidh_conn.c l2c_api.c l2c_csm.c l2c_link.c l2c_main.c l2c_utils.c port_api.c port_rfc.c port_utils.c rfc_l2cap_if.c rfc_mx_fsm.c rfc_port_fsm.c rfc_port_if.c rfc_ts_frames.c rfc_utils.c sdp_api.c sdp_db.c sdp_discovery.c sdp_main.c sdp_server.c sdp_utils.c db.c dsp.c dsp_debug.c dsp_task.c dvdfs.c dvd.c dvdqueue.c dvderror.c dvdidutils.c dvdFatal.c dvd_broadway.c euart.c EXIBios.c EXIUart.c EXICommon.c fs.c GXInit.c GXFifo.c GXAttr.c GXMisc.c GXGeometry.c GXFrameBuf.c GXLight.c GXTexture.c GXBump.c GXTev.c GXPixel.c GXDisplayList.c GXTransform.c GXPerf.c HBMBase.cpp HBMAnmController.cpp HBMFrameController.cpp HBMGUIManager.cpp HBMController.cpp HBMRemoteSpk.cpp db_assert.cpp db_console.cpp db_DbgPrintBase.cpp db_directPrint.cpp db_mapFile.cpp lyt_animation.cpp lyt_arcResourceAccessor.cpp lyt_bounding.cpp lyt_common.cpp lyt_drawInfo.cpp lyt_group.cpp lyt_layout.cpp lyt_material.cpp lyt_pane.cpp lyt_picture.cpp lyt_resourceAccessor.cpp lyt_textBox.cpp lyt_window.cpp math_triangular.cpp snd_AnimSound.cpp snd_AxManager.cpp snd_AxVoice.cpp snd_Bank.cpp snd_BankFile.cpp snd_BasicSound.cpp snd_Channel.cpp snd_DisposeCallbackManager.cpp snd_DvdSoundArchive.cpp snd_EnvGenerator.cpp snd_ExternalSoundPlayer.cpp snd_FrameHeap.cpp snd_InstancePool.cpp snd_Lfo.cpp snd_MemorySoundArchive.cpp snd_MidiSeqPlayer.cpp snd_MidiSeqTrack.cpp snd_MmlParser.cpp snd_MmlSeqTrack.cpp snd_MmlSeqTrackAllocator.cpp snd_NandSoundArchive.cpp snd_PlayerHeap.cpp snd_RemoteSpeaker.cpp snd_RemoteSpeakerManager.cpp snd_SeqFile.cpp snd_SeqPlayer.cpp snd_SeqSound.cpp snd_SeqSoundHandle.cpp snd_SeqTrack.cpp snd_SoundArchive.cpp snd_SoundArchiveFile.cpp snd_SoundArchiveLoader.cpp snd_SoundArchivePlayer.cpp snd_SoundHandle.cpp snd_SoundHeap.cpp snd_SoundPlayer.cpp snd_SoundStartable.cpp snd_SoundSystem.cpp snd_SoundThread.cpp snd_StrmChannel.cpp snd_StrmFile.cpp snd_StrmPlayer.cpp snd_StrmSound.cpp snd_StrmSoundHandle.cpp snd_TaskManager.cpp snd_TaskThread.cpp snd_Util.cpp snd_WaveFile.cpp snd_WavePlayer.cpp snd_WaveSound.cpp snd_WaveSoundHandle.cpp snd_WsdFile.cpp snd_WsdPlayer.cpp snd_WsdTrack.cpp ut_binaryFileFormat.cpp ut_CharStrmReader.cpp ut_CharWriter.cpp ut_DvdFileStream.cpp ut_DvdLockedFileStream.cpp ut_FileStream.cpp ut_Font.cpp ut_IOStream.cpp ut_LinkList.cpp ut_list.cpp ut_ResFont.cpp ut_ResFontBase.cpp ut_TagProcessorBase.cpp ut_TextWriterBase.cpp ipcMain.c ipcclt.c memory.c ipcProfile.c KPAD.c mem_heapCommon.c mem_expHeap.c mem_frameHeap.c mem_unitHeap.c mem_allocator.c mem_list.c mix.c remote.c mtx.c mtxvec.c mtx44.c vec.c psmtx.c nand.c NANDOpenClose.c NANDCore.c NANDCheck.c OS.c OSAlarm.c OSAlloc.c OSArena.c OSAudioSystem.c OSCache.c OSContext.c OSError.c OSExec.c OSFatal.c OSFont.c OSInterrupt.c OSLink.c OSMessage.c OSMemory.c OSMutex.c OSReboot.c OSReset.c OSRtc.c OSSemaphore.c OSSync.c OSThread.c OSTime.c OSUtf.c OSIpc.c OSStateTM.c __start.c OSPlayRecord.c OSStateFlags.c OSNet.c OSNandbootInfo.c __ppc_eabi_init.cpp Pad.c scsystem.c scapi.c scapi_prdinfo.c seq.c SIBios.c SISamplingRate.c syn.c TPL.c usb.c vi.c i2c.c vi3in1.c wenc.c WPAD.c WPADHIDParser.c WPADEncrypt.c WPADMem.c debug_msg.c WUD.c WUDHidHost.c debug_msg.c DebuggerDriver.c exi2.c float.cpp alloc.c ansi_files.c ansi_fp.c arith.c buffer_io.c ctype.c direct_io.c errno.c file_io.c FILE_POS.C locale.c mbstring.c mem.c mem_funcs.c math_api.c misc_io.c printf.c qsort.c rand.c scanf.c signal.c string.c strtold.c strtoul.c wctype.c wstring.c wchar_io.c uart_console_io_gcn.c abort_exit_ppc_eabi.c math_sun.c extras.c e_atan2.c e_exp.c e_fmod.c e_log.c e_log10.c e_pow.c e_rem_pio2.c k_cos.c k_rem_pio2.c k_sin.c k_tan.c s_atan.c s_ceil.c s_copysign.c s_cos.c s_floor.c s_frexp.c s_ldexp.c s_sin.c s_tan.c w_atan2.c w_exp.c w_fmod.c w_log.c w_log10.c w_pow.c e_sqrt.c math_ppc.c w_sqrt.c __mem.c __va_arg.c global_destructor_chain.c NMWException.cp ptmf.c runtime.c __init_cpp_exceptions.cpp Gecko_ExceptionPPC.cp GCN_mem_alloc.c mainloop.c nubevent.c nubinit.c msg.c msgbuf.c serpoll.c usr_put.c dispatch.c msghndlr.c support.c mutex_TRK.c notify.c flush_cache.c mem_TRK.c string_TRK.c __exception.s targimpl.c targsupp.s mpc_7xx_603e.c mslsupp.c dolphin_trk.c main_TRK.c dolphin_trk_glue.c targcont.c target_options.c UDP_Stubs.c main.c CircleBuffer.c MWCriticalSection_gc.cpp HashKeyFunctions.cpp MemMan.cpp Random.cpp RelocatableChunk.cpp fmod_eventi.cpp fmod_eventsystemi.cpp fmod_sounddef.cpp fmod_eventcategoryi.cpp fmod_eventparameteri.cpp fmod_eventprojecti.cpp fmod_eventgroupi.cpp fmod_reverbdef.cpp fmod_channel_revolution.cpp fmod_os_misc.cpp fmod_os_output.cpp fmod_output_revolution.cpp fmod_sample_revolution.cpp fmod_dsp.cpp fmod_dspi.cpp fmod_codec_aiff.cpp fmod_codec_dsp.cpp fmod_codec_fsb.cpp fmod_codec_user.cpp fmod.cpp fmod_async.cpp fmod_channel.cpp fmod_channel_emulated.cpp fmod_channel_real.cpp fmod_channel_realmanual3d.cpp fmod_channel_stream.cpp fmod_channeli.cpp fmod_channelpool.cpp fmod_channelgroup.cpp fmod_channelgroupi.cpp fmod_codec.cpp fmod_debug.cpp fmod_file.cpp fmod_file_disk.cpp fmod_file_memory.cpp fmod_file_null.cpp fmod_file_user.cpp fmod_listener.cpp fmod_memory.cpp fmod_metadata.cpp fmod_output.cpp fmod_output_emulated.cpp fmod_output_polled.cpp fmod_plugin.cpp fmod_pluginfactory.cpp fmod_sound.cpp fmod_sound_sample.cpp fmod_sound_stream.cpp fmod_soundi.cpp fmod_string.cpp fmod_stringw.cpp fmod_system.cpp fmod_systemi.cpp fmod_thread.cpp fmod_time.cpp fmod_globals.cpp fmod_output_nosound.cpp fmod_output_nosound_nrt.cpp fmod_reverbi.cpp fmod_speakerlevels_pool.cpp
submitted by SSor3nt to ManhuntGames [link] [comments]

C++ Best Practices For a C Programmer

Hi all,
Long time C programmer here, primarily working in the embedded industry (particularly involving safety-critical code). I've been a lurker on this sub for a while but I'm hoping to ask some questions regarding best practices. I've been trying to start using c++ on a lot of my work - particularly taking advantage of some of the code-reuse and power of C++ (particularly constexpr, some loose template programming, stronger type checking, RAII etc).
I would consider myself maybe an 8/10 C programmer but I would conservatively maybe rate myself as 3/10 in C++ (with 1/10 meaning the absolute minmum ability to write, google syntax errata, diagnose, and debug a program). Perhaps I should preface the post that I am more than aware that C is by no means a subset of C++ and there are many language constructs permitted in one that are not in the other.
In any case, I was hoping to get a few answers regarding best practices for c++. Keep in mind that the typical target device I work with does not have a heap of any sort and so a lot of the features that constitute "modern" C++ (non-initialization use of dynamic memory, STL meta-programming, hash-maps, lambdas (as I currently understand them) are a big no-no in terms of passing safety review.

When do I overload operators inside a class as opposed to outisde?


... And what are the arguments foagainst each paradigm? See below:
/* Overload example 1 (overloaded inside class) */ class myclass { private: unsigned int a; unsigned int b; public: myclass(void); unsigned int get_a(void) const; bool operator==(const myclass &rhs); }; bool myclass::operator==(const myclass &rhs) { if (this == &rhs) { return true; } else { if (this->a == rhs.a && this->b == rhs.b) { return true; } } return false; } 
As opposed to this:

/* Overload example 2 (overloaded outside of class) */ class CD { private: unsigned int c; unsigned int d; public: CD(unsigned int _c, unsigned int _d) : d(_d), c(_c) {}; /* CTOR */ unsigned int get_c(void) const; /* trival getters */ unsigned int get_d(void) const; /* trival getters */ }; /* In this implementation, If I don't make the getters (get_c, get_d) constant, * it won't compile despite their access specifiers being public. * * It seems like the const keyword in C++ really should be interpretted as * "read-only AND no side effects" rather than just read only as in C. * But my current understanding may just be flawed... * * My confusion is as follows: The function args are constant references * so why do I have to promise that the function methods have no side-effects on * the private object members? Is this something specific to the == operator? */ bool operator==(const CD & lhs, const CD & rhs) { if(&lhs == &rhs) return true; else if((lhs.get_c() == rhs.get_c()) && (lhs.get_d() == rhs.get_d())) return true; return false; } 
When should I use the example 1 style over the example 2 style? What are the pros and cons of 1 vs 2?

What's the deal with const member functions?

This is more of a subtle confusion but it seems like in C++ the const keyword means different things base on the context in which it is used. I'm trying to develop a relatively nuanced understanding of what's happening under the hood and I most certainly have misunderstood many language features, especially because C++ has likely changed greatly in the last ~6-8 years.

When should I use enum classes versus plain old enum?


To be honest I'm not entirely certain I fully understand the implications of using enum versus enum class in C++.
This is made more confusing by the fact that there are subtle differences between the way C and C++ treat or permit various language constructs (const, enum, typedef, struct, void*, pointer aliasing, type puning, tentative declarations).
In C, enums decay to integer values at compile time. But in C++, the way I currently understand it, enums are their own type. Thus, in C, the following code would be valid, but a C++ compiler would generate a warning (or an error, haven't actually tested it)
/* Example 3: (enums : Valid in C, invalid in C++ ) */ enum COLOR { RED, BLUE, GREY }; enum PET { CAT, DOG, FROG }; /* This is compatible with a C-style enum conception but not C++ */ enum SHAPE { BALL = RED, /* In C, these work because int = int is valid */ CUBE = DOG, }; 
If my understanding is indeed the case, do enums have an implicit namespace (language construct, not the C++ keyword) as in C? As an add-on to that, in C++, you can also declare enums as a sort of inherited type (below). What am I supposed to make of this? Should I just be using it to reduce code size when possible (similar to gcc option -fuse-packed-enums)? Since most processors are word based, would it be more performant to use the processor's word type than the syntax specified above?
/* Example 4: (Purely C++ style enums, use of enum class/ enum struct) */ /* C++ permits forward enum declaration with type specified */ enum FRUIT : int; enum VEGGIE : short; enum FRUIT /* As I understand it, these are ints */ { APPLE, ORANGE, }; enum VEGGIE /* As I understand it, these are shorts */ { CARROT, TURNIP, }; 
Complicating things even further, I've also seen the following syntax:
/* What the heck is an enum class anyway? When should I use them */ enum class THING { THING1, THING2, THING3 }; /* And if classes and structs are interchangable (minus assumptions * about default access specifiers), what does that mean for * the following definition? */ enum struct FOO /* Is this even valid syntax? */ { FOO1, FOO2, FOO3 }; 
Given that enumerated types greatly improve code readability, I've been trying to wrap my head around all this. When should I be using the various language constructs? Are there any pitfalls in a given method?

When to use POD structs (a-la C style) versus a class implementation?


If I had to take a stab at answering this question, my intuition would be to use POD structs for passing aggregate types (as in function arguments) and using classes for interface abstractions / object abstractions as in the example below:
struct aggregate { unsigned int related_stuff1; unsigned int related_stuff2; char name_of_the_related_stuff[20]; }; class abstraction { private: unsigned int private_member1; unsigned int private_member2; protected: unsigned int stuff_for_child_classes; public: /* big 3 */ abstraction(void); abstraction(const abstraction &other); ~abstraction(void); /* COPY semantic ( I have a better grasp on this abstraction than MOVE) */ abstraction &operator=(const abstraction &rhs); /* MOVE semantic (subtle semantics of which I don't full grasp yet) */ abstraction &operator=(abstraction &&rhs); /* * I've seen implentations of this that use a copy + swap design pattern * but that relies on std::move and I realllllly don't get what is * happening under the hood in std::move */ abstraction &operator=(abstraction rhs); void do_some_stuff(void); /* member function */ }; 
Is there an accepted best practice for thsi or is it entirely preference? Are there arguments for only using classes? What about vtables (where byte-wise alignment such as device register overlays and I have to guarantee placement of precise members)

Is there a best practice for integrating C code?


Typically (and up to this point), I've just done the following:
/* Example 5 : Linking a C library */ /* Disable name-mangling, and then give the C++ linker / * toolchain the compiled * binaries */ #ifdef __cplusplus extern "C" { #endif /* C linkage */ #include "device_driver_header_or_a_c_library.h" #ifdef __cplusplus } #endif /* C linkage */ /* C++ code goes here */ 
As far as I know, this is the only way to prevent the C++ compiler from generating different object symbols than those in the C header file. Again, this may just be ignorance of C++ standards on my part.

What is the proper way to selectively incorporate RTTI without code size bloat?

Is there even a way? I'm relatively fluent in CMake but I guess the underlying question is if binaries that incorporate RTTI are compatible with those that dont (and the pitfalls that may ensue when mixing the two).

What about compile time string formatting?


One of my biggest gripes about C (particularly regarding string manipulation) frequently (especially on embedded targets) variadic arguments get handled at runtime. This makes string manipulation via the C standard library (printf-style format strings) uncomputable at compile time in C.
This is sadly the case even when the ranges and values of paramers and formatting outputs is entirely known beforehand. C++ template programming seems to be a big thing in "modern" C++ and I've seen a few projects on this sub that use the turing-completeness of the template system to do some crazy things at compile time. Is there a way to bypass this ABI limitation using C++ features like constexpr, templates, and lambdas? My (somewhat pessimistic) suspicion is that since the generated assembly must be ABI-compliant this isn't possible. Is there a way around this? What about the std::format stuff I've been seeing on this sub periodically?

Is there a standard practice for namespaces and when to start incorporating them?

Is it from the start? Is it when the boundaries of a module become clearly defined? Or is it just personal preference / based on project scale and modularity?
If I had to make a guess it would be at the point that you get a "build group" for a project (group of source files that should be compiled together) as that would loosely define the boundaries of a series of abstractions APIs you may provide to other parts of a project.
--EDIT-- markdown formatting
submitted by aWildElectron to cpp_questions [link] [comments]

more related issues


more related issues
in the conversion of old and new systems, the most difficult one is uuuuuuuuuuuuuuu.

  1. Among the following options, the one that does not belong to the combination of two parameters, one change and three combinations:
    the form control that can accept numerical data input is.

Internal gateway protocol is divided into: distance vector routing protocol, and hybrid routing protocol.

Firewall can prevent the transmission of infected software or files
among the following coupling types, the lowest coupling degree is ().

The () property of the Navigator object returns the platform and version information of the browser.

What are the main benefits of dividing IP subnets? ()
if users want to log in to the remote server and become a simulation terminal of the remote server temporarily, they can use the
[26-255] software life cycle provided by the remote host, which means that most operating systems, such as DOS, windows, UNIX, etc., adopt tree structureFolder structure.

An array is a group of memory locations related by the fact that they all have __________ name and __________ Type.
in Windows XP, none of the characters in the following () symbol set can form a file name. [2008 vocational college]
among the following options, the ones that do not belong to the characteristics of computer viruses are:
in the excel 2010 cell Format dialog box, the nonexistent tab is
the boys___ The teacher talked to are from class one.
for an ordered table with length of 18, if the binary search is used, the length of the search for the 15th element is ().

SRAM memory is______ Memory.

() is a website with certain complementary advantages. It places the logo or website name of the other party's website on its own website, and sets the hyperlink of each other's website, so that users can find their own website from the cooperative website and achieve the purpose of mutual promotion.

  1. Accounting qualification is managed by information technology ()
    which of the following devices can forward the communication between different VLANs?

The default port number of HTTP hypertext transfer protocol is:
forIn the development method of object, () will be the dominant standard modeling language in the field of object-oriented technology.

When you visit a website, what is the first page you see?

File D:\\ city.txt The content is as follows: Beijing Tianjin Shanghai Chongqing writes the following event process: privatesub form_ click() Dim InD Open \d:\\ city.txt \For input as ? 1 do while not EOF (1) line input ? 1, Ind loop close 1 print ind End Sub run the program, click the form, and the output result is.

When users use dial-up telephone lines to access the Internet, the most commonly used protocol is.

In the I2C system, the main device is usually taken by the MCU with I2C bus interface, and the slave device must have I2C bus interface.

The basic types of market research include ()
the function of the following program is: output all integers within 100 that can be divisible by 3 and have single digits of 6. What should be filled in the underline is (). 56b33287e4b0e85354c031b5. PNG
the infringement of the scope of intellectual property rights is:
multimedia system is a computer that can process sound and image interactivelySystem.

In order to allow files of different users to have the same file name, () is usually used in the file system.

The following () effects are not included in PowerPoint 2010 animation effects.

Macro virus can infect________ Documents.

The compiled Java program can be executed directly.

In PowerPoint, when adding text to a slide with AutoShape, how to indicate that text can be edited on the image when an AutoShape is selected ()
organizational units can put users, groups, computers and other units into the container of the active directory.

Ethernet in LAN adopts the combination technology of packet switching and circuit switching. ()
interaction designers need to design information architecture and interface details.

In the process of domain name resolution, the local domain name server queries the root domain name server by using the search method.

What stage of e-commerce system development life cycle does data collection and processing preparation belong to?

Use the "ellipse" tool on the Drawing toolbar of word, press the () key and drag the mouse to draw a circle.

The proportion of a country's reserve position in the IMF, including the convertible currency part of the share subscribed by Member States to the IMF, and the portion that can be paid in domestic currency, respectively.

  1. When installing Windows 7 operating system, the system disk partition must be in format before installation.

High rise buildings, public places of entertainment and other decoration, in order to prevent fire should be used____。 ()
with regard to the concept of area in OSPF protocol, what is wrong in the following statements is ()
suppose that the channel bandwidth is 4000Hz and the modulation is 256 different symbols. According to the Nyquist theorem, the data rate of the ideal channel is ()
which of the following is the original IEEE WLAN standard ()?

What is correct about data structure is:
the key deficiency of waterfall model is that ().

The software development mode with almost no product plan, schedule and formal development process is
in the following description of computers, the correct one is ﹥
Because human eyes are sensitive to chroma signal, the sampling frequency of luminance signal can be lower than that of chroma signal when video signal is digitized, so as to reduce the amount of digital video data.

[47-464] what is correct in the following statements is
ISO / IEC WG17 is responsible for the specific drafting, discussion, amendment, formulation, voting and publication of the final ISO international standards for iso14443, iso15693 and iso15693 contactless smart lock manufacturers smart card standards.

Examples of off - balance - sheet activities include _________

The correct description of microcomputer is ().

Business accident refers to the accident caused by the failure of operation mechanism of tourism service department. It can be divided into ().

IGMP Network AssociationWhat is the function of the discussion?

Using MIPS as the unit to measure the performance of the computer, it refers to the computer______

In the excel workbook, after executing the following code, the value of cell A3 of sheet 1 is________ Sub test1() dim I as integer for I = 1 to 5 Sheet1. Range (\ \ a \ \ & I) = I next inend sub
What are the characteristics of electronic payment compared with traditional payment?

When the analog signal is encoded by linear PCM, the sampling frequency is 8kHz, and the code energy control unit is 8 bits, then the information transmission rate is ()
  1. The incorrect discussion about the force condition of diesel engine connecting rod is.

Software testing can be endless.

The game software running on the windows platform of PC is sent to the mobile phone of Android system and can run normally.

The following is not true about the video.

The way to retain the data in the scope of request is ()
distribution provides the basis and support for the development of e-commerce.

  1. Which of the following belong to the content of quality control in the analysis
    1. During the operation of a program, the CNC system appears "soft limit switch overrun", which belongs to
    2. The wrong description of the gas pipe is ()
    3. The following statement is wrong: ()
    the TCP / IP protocol structure includes () layer.

Add the records in table a to table B, and keep the original records in table B. the query that should be used is.

For additives with product anti-counterfeiting certification mark, after confirming that the product is in conformity with the factory quality certificate and the real object, one copy () shall be taken and pasted on the ex factory quality certificate of the product and filed together.

() accounts are disabled by default.

A concept of the device to monitor a person's bioparameters is that it should.
  1. For the cephalic vein, the wrong description is
    an image with a resolution of 16 pixels × 16 pixels and a color depth of 8 bits, with the data capacity of at least______ Bytes. (0.3 points)
  2. What are the requirements for the power cord of hand-held electric tools?

In the basic mode of electronic payment, credit card belongs to () payment system.

The triode has three working states: amplification, saturation and cut-off. In the digital circuit, when the transistor is used as a switch, it works in two states of saturation or cut-off.

Read the attached article and answer the following: compared with today's music, those of the past
() refers to the subjective conditions necessary for the successful completion of an activity.

In the OSI reference model, what is above the network layer is_______ 。

The decision tree corresponding to binary search is not only a binary search tree, but also an ideal balanced binary tree. In order to guide the interconnection, interoperability and interoperability of computer networks, ISO has issued the OSI reference model, and its basic structure is divided into
26_______ It belongs to the information system operation document.

In C ? language, the following operators have the highest priority___ ?
the full Chinese name of BPR is ()
please read the following procedures: dmain() {int a = 5, B = 0, C = 0; if (a = B + C) printf (\ * * \ n \); else printf (\ $$n \);} the above programs
() software is not a common tool for web page making.

When a sends a message to B, in order to achieve security, a needs to encrypt the message with ().

The Linux exchange partition is used to save the visited web page files.

  1. Materials consumed by the basic workshop may be included in the () cost item.

The coverage of LAN is larger than that of Wan.

Regarding the IEEE754 standard of real number storage, the wrong description is______

Task 4: convert decimal number to binary, octal and hexadecimal number [Topic 1] (1134.84375) 10 = () 2=()8 = () 16
the purpose of image data compression is to ()
in IE browser, to view the frequently visited sites that have been saved, you need to click.

  1. When several companies jointly write a document, the document number of each company should be quoted in the header at the same time. ()
    assuming that the highest frequency of analog signal is 10MHz, and the sampling frequency must be greater than (), then the sample signal can not be distorted.

The incredible performing artist from Toronto.
in access, the relationship between a table and a database is.

In word 2010, the following statement about the initial drop is correct.

Interrupt service sub function does not need to be called in the program, but after applying for interrupt, the CPU automatically finds the corresponding program according to the interrupt number.

Normal view mode is the default view mode for word documents.

A common variable is defined as follows: Union data {int a; int b; float C;} data; how much memory space does the variable data occupy in VC6.0?

______ It is not a relational database management system.

In the basic model of decision support system, what is in the core position is:
among the following key factors of software outsourcing projects, () is the factor that affects the final product quality and production efficiency of software outsourcing.

Word Chinese textThe shortcut for copying is ().
submitted by Amanda2020-jumi to u/Amanda2020-jumi [link] [comments]

Tutorial: Using Borg for backup your QNAP to other devices (Advanced - CLI only)

Tutorial: Using Borg for backup your QNAP to other devices (Advanced - CLI only)
This tutorial will explain how to use Borg Backup to perform backups. This tutorial will specifically be aimed to perform backups from our QNAP to another unit (another NAS in your LAN, external hard drive, any off-site server, etc). But it is also a great tool to backup your computers to your NAS. This tutorial is a little bit more technical than the previous, so, be patient :)
MASSIVE WALL OF TEXT AHEAD. You have been warned.
Why Borg instead of, let’s say HBS3? Well, Borg is one of the best -if not THE BEST- backup software available. It is very resilient to failure and corruption. Personally I’m in love with Borg. It is a command line based tool. That means that there is no GUI available (there are a couple of front-end created by community, though). I know that can be very intimidating at first when you are not accustomed to it, and that it looks ugly, but honestly, it is not so complicated, and if you are willing to give it a try, I can assure you that is simple and easy. You might even like it over time!
https://www.borgbackup.org/
That aside, I have found that HBS3 can only perform incremental backups when doing QNAP-QNAP backups. It can use Rsync to save files to a non-QNAP device, but then you can’t use incremental (and IIRC, neither Deduplication or encryption). It will even refuse to save to a mounted folder using hybrid mount. QNAP seems to be trying to subtle lock you down in their ecosystem. Borg has none of those limitations.

Main pros of Borg Backup:
- VERY efficient and powerful
- Space efficient thanks to deduplication and compression
- Allows encryption, deduplication, incremental, compression… you name it.
- Available in almost any OS (except Windows) and thanks to Docker, even in Windows. There are also ARM binaries, so it is Raspberry compatible, and even ARM based QNAPs that don’t support docker can use it!!!
- Since it’s available in most OS, you can use a single unified solution for all your backups.
- Can make backups in PUSH and PULL style. Either each machine with Borg pushes the files into the server, or a single server with Borg installed pulls the files from any device without needing to install Borg on those devices.
- It is backed by a huge community with tons of integration and wrapper tools (https://github.com/borgbackup/community)
- Supports Backup to local folders, LAN backups using NFS or SMB, and also remote backups using SFTP or mounting SSHFS.
- IT IS FOSS. Seriously, guys, whenever possible, choose FOSS.

Cons of Borg Backup:
- It is not tailored for backups to cloud services like Drive or Mega. You might want to take a look at Rclone or Restic for that.
- It lacks GUI, so everything is CLI controlled. I know, it can be very intimidating, but once you have used it for a couple of days, you will notice how simple and comfortable to use is.

The easiest way to run Borg is to just grab the appropriate prebuilt binary (https://github.com/borgbackup/borg/releases) and run it baremetal, but I’m going to show how to install Borg in a docker container so you can apply this solution to any other scenario where docker is available. If you want to skip the container creation, just proceed directly to step number 2.

**FIRST STEP: LET'S BUILD THE CONTAINER**
There is currently no official Borg prebuilt container (although there are non-official ones). Since it’s a CLI tool, you don’t really need a prebuilt container, you can just use your preferred one (Ubuntu, Debian, Alpine etc) and install Borg directly in your container. We are using a ubuntu:latest container because the available Borg version for ubuntu is up to date. For easiness, all those directories we want to backup will be mounted inside the container in /output.
If you already are familiar with SSH and container creation though CLI, just user this template, substituting your specific directories mount.
docker run -it \ --cap-add=NET_ADMIN \ --net=bridge \ --privileged \ --cap-add SYS_ADMIN \ --device /dev/fuse \ --security-opt apparmor:unconfined \ --name=borgbackup \ -v /share/Movies:/output/Movies:ro \ -v /share/Important/Documents:/output/Documents:ro \ -v /share/Other:/output/Other:ro \ -v /share/Containeborgbackup/persist:/persist \ -v /etc/localtime:/etc/localtime:ro \ ubuntu:latest 
(REMEMBER: LINUX IS CAPITAL SENSIBLE, SO CAPITALS MATTER!!)
Directories to be backup are mounted as read only (:ro) for extra safety. I have also found that mounting another directory as “persistent” directory makes easy to create and edit the needed scripts directly from File Finder in QNAP, and also allows to keep them in case you need to destroy or recreate the container: this is the “/persist” directory. Use your favorite path.
If you are not familiar with SSH, first go here to learn how to activate and login into your QNAP using SSH (https://www.qnap.com/en/how-to/knowledge-base/article/how-to-access-qnap-nas-by-ssh/).
You can also use the GUI in Container Station to create the container and mount folders in advanced tab during container creation. Please, refer to QNAP’s tutorials about Docker.
GUI example
If done correctly, you will see that this container appears in the overview tab of Container Station. Click the name, and then click the two arrows. That will transport you to another tab inside the container to start working.
https://preview.redd.it/5y09skuxrvj41.jpg?width=1440&format=pjpg&auto=webp&s=19e4b22d6458d2c9a8143c9841f070828bcf5170

**SECOND STEP: INSTALLING BORG BACKUP INSIDE THE CONTAINER**
First check that the directory with all the data you want to backup (/output in our example) is mounted. If you can’t see anything, then you did something wrong in the first step when creating the container. If so, delete the container and try again. Now navigate to /persist using “cd /persist”
See how /output contains to-be-backup directories
Now, we are going to update ubuntu and install some dependencies and apps we need to work. Copy and paste this:
apt update && apt upgrade -y apt install -y nano fuse software-properties-common nfs-common ssh 
It will install a lot of things. Just let it work. When finished, install borgbackup using
add-apt-repository -y ppa:costamagnagianfranco/borgbackup apt install -y borgbackup 
When it’s finished, run “borg --version” and you will be shown the current installed version (at time of writing this current latest is 1.1.10). You already have Borg installed!!!!
1.1.10 is latest version at the time of this tutorial creation

**THIRD STEP: PREPARING THE BACKUP DEVICE USING NFS MOUNT**
Now, to init the repository, we first need to choose where we want to make the backup. Borg can easily make “local” backups, choosing a local folder, but that defeats the purpose for backups, right? We want to create remote repositories.
If you are making backups to a local (same network) device (another NAS, a computer, etc) then you can choose to use SFTP (SSH file transfer) or just NFS or SMB to mount a folder. If you want to backup to a remote repository outside your LAN (the internet) you HAVE to use SFTP or SSHFS. I’m explaining now how to mount folder using NFS, leaving SFTP for later.
Borg can work in two different ways: PUSH style or PULL style.
In PUSH style, each unit to be backup have Borg installed and it “pushes” the files to a remote folder using NFS, SMB or SSHFS. The target unit do not need to have Borg installed.
PUSH style backup: The QNAP sends files to the backup device

In PULL style, the target unit that is going to receive the backups has Borg installed, and it “pulls” the files from the units to be backup (and so, they don’t need Borg installed) using NFS, SMB or SSHFS. This is great if you have a powerful NAS unit and want to backup several computers.
PULL style backup: The backup device gets files from QNAP. Useful for multiple unit backups into the same backup server.

When using SFTP, the backup unit has Borg installed, opens a secure SSH connection to target unit, connects with Borg in target machine, and uploads the files. In SFTP style, BOTH units need Borg installed.
SFTP: Borg needs to be installed in both devices, and they \"talk\" each other.

I’m assuming you have another device with IP “192.168.1.200” (in my example I’m using a VM with that IP) with a folder called “/backup” inside. I’m also assuming that you have correctly authorized NFS mount with read/write permissions between both devices. If you don’t now how to, you’ll need to investigate. (https://www.qnap.com/en-us/how-to/knowledge-base/article/how-to-enable-and-setup-host-access-for-nfs-connection/)
NFS mount means mirroring two folders from two different devices. So, mounting folder B from device Y into folder A from device X means that even if the folder B is “physically” stored on device Y, the device X can use it exactly as if it was folder A inside his local path. If you write something to folder A, folder B will automatically be updated with that new file and vice-versa.
Graphical example of what happens when mounting folders in Linux system.
Mount usage is: “mount [protocol] [targetIP]:/target/directory /local/directory” So, go to your container and write:
mount -t nfs 192.168.1.200:/backup /mnt 
Mount is the command to mount. “-t nfs” means using NFS, if you want to use SMB you would use “-t cifs”. 192.168.1.200 is the IP of the device where you are going to make backups. /backup is the directory in the target we want to save our backups to (remember you need to correctly enable permission for NFS server sharing in the target device). /mnt is the directory in the container where the /backup folder will be mounted.
OK, so now /mnt in container = /backup in target. If you drop a .txt file in one of those directories, it will immediately appear on the other. So… All we have to do now is make a borg repository on /mnt and wildly start making backups. /mnt will be our working directory.

**FOURTH STEP: ACTUALLY USING BORG** (congrats if you made it here)
Read the documentation
https://borgbackup.readthedocs.io/en/stable/usage/general.html
It’s madness. Right?. It’s OK. In fact we only need a very few borg commands to make it work.
“borg init” creates a repository, that is, a place where the backup files are stored.
“borg create” makes a backup
“borg check” checks backup integrity
“borg prune” prunes the backup (deletes older files)
“borg extract” extract files from a backup
“borg mount” mounts a backup as if it was a directory and you can navigate it
“borg info” gives you info from the repository
“borg list” shows every backup inside the repository
But since we are later using pre-made scripts for backup, you will only need to actually use “init”, “info” and “list” and in case of recovery, “mount”.
let’s create our repository using INIT
https://borgbackup.readthedocs.io/en/stable/usage/init.html
borg init -e [encryption] [options] /mnt 
So, if you want to encrypt the repository with a password (highly recommended) use “-e repokey” or “-e repokey-blake2”. If you want to use a keyfile instead, use “-e keyfile”. If you don’t want to encrypt, use “-e none”. If you want to set a maximum space quota, use “--storage-quota ” to avoid excessive storage usage (I.e “--storage-quota 500G” or “--storage-quota 2.5T”). Read the link above. OK, so in this example:
borg init -e repokey –storage-quota 200G /mnt 
You will be asked for a password. Keep this password safe. If you lose it, you lose your backups!!!! Once finished, we have our repository ready to create the first backup. If you use “ls /mnt” you will see than the /mnt directory is no longer empty, but contains several files. Those are the repository files, and now should also be present in your backup device.
init performed successfully
Let’s talk about actually creating backups. Usually, you would create a backup using the “borg create” backup command, using something like this:
borg create -l -s /mnt::Backup01 /output --exclude ‘*.py’ 
https://borgbackup.readthedocs.io/en/stable/usage/create.html
That would create a backup archive called “backup01” of all files and directories in /output, but excluding every .py file. It will also verbose all files (-l) and stats (-s) during the process. If you later write the same but with “Backup02”, only new added files will be saved (incremental) but deleted files will still be available in “Backup01”. So as new backups are made, you will end running out of storage space. To avoid this you would need to schedule pruning.
https://borgbackup.readthedocs.io/en/stable/usage/prune.html
borg prune [options] [path/to/repo] is used to delete old backups based on your specified options (I.e “save 4 last year backups, 1 backups each month last year, and 1 daily last month).
BUT. To make is simple, we just need to create a script that will automatically 1) Create a new backup with specified name and 2) run a Prune with specified retention policy.
Inside the container head to /persist using “cd /persist”, and create a file called backup.sh using
touch backup.sh chmod 700 backup.sh nano backup.sh 
Then, copy the following and paste it inside nano using CTRL+V
#!/bin/sh # Setting this, so the repo does not need to be given on the command line: export BORG_REPO=/mnt # Setting this, so you won't be asked for your repository passphrase: export BORG_PASSPHRASE='YOURsecurePASS' # or this to ask an external program to supply the passphrase: # export BORG_PASSCOMMAND='pass show backup' # some helpers and error handling: info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM info "Starting backup" # Backup the most important directories into an archive named after # the machine this script is currently running on: borg create \ --verbose \ --filter AME \ --list \ --stats \ --show-rc \ --compression lz4 \ --exclude-caches \ --exclude '*@Recycle/*' \ --exclude '*@Recently-Snapshot/*' \ --exclude '*[email protected]__thumb/*' \ \ ::'QNAP-{now}' \ /output \ backup_exit=$? info "Pruning repository" # Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly # archives of THIS machine. The 'QNAP-' prefix is very important to # limit prune's operation to this machine's archives and not apply to # other machines' archives also: borg prune \ --list \ --prefix 'QNAP-' \ --show-rc \ --keep-daily 7 \ --keep-weekly 4 \ --keep-monthly 6 \ prune_exit=$? # use highest exit code as global exit code global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) if [ ${global_exit} -eq 0 ]; then info "Backup and Prune finished successfully" elif [ ${global_exit} -eq 1 ]; then info "Backup and/or Prune finished with warnings" else info "Backup and/or Prune finished with errors" fi exit ${global_exit} 
This script seems very complicated, but all it does is
  1. Define the backup location
  2. Define backup parameters, inclusions and exclusions and run backup
  3. Define pruning policy and run prune
  4. Show stats
You can freely modify it using the options you need (they are described in the documentation).
“export BORG_REPO=/mnt” is where the repository is located.
“export BORG_PASSPHRASE='YOURsecurePASS' is your repository password (between the single quotes)
After “borg create” some options are defined, like compression, file listing and stat showing. Then exclusion are defined (each –exclude defines one exclusion rules. In this example I have defined rules to avoid backup thumbnails, recycle bin files, and snapshots). If you wish to exclude mode directories or files, you do it adding a new rule there.
::'QNAP-{now}' defines how backups will be named. Right now they will be named as QNAP-”current date and time”. In case you want only current date and not time used, you can use instead:
::'QNAP-{now:%Y-%m-%d}' \
Be aware that if you decide to do so, you will only be able to create a single backup each day, as subsequent backups the same day will fail, since Borg will find another backup with same name and skip the current one.
/output below is the directory to be backup.
And finally, prune policy is at the end. This defines what backups will be kept and which ones will be deleted. Current defined policy is to keep 7 end of day, then 4 end of week and 6 end of month backups. Extra backups will be deleted. You can modify this depending on your needs. Follow the documentation for extra information and examples.
https://borgbackup.readthedocs.io/en/stable/usage/prune.html
Now save the script using CTRL+O. We are ready. Run the script using:
./backup.sh
It will show progress, including what files are being saved. After finishing, it will return backup name (in this example “QNAP-2020-01-26T01:05:36“ is the name of the backup archive), stats and will return two rc status, one for the backup, and another for pruning. “rc0” means success. “rc1” means finished, but with some errors. “rc2” means failed. You should be returned two rc0 status and the phrase “Backup and Prune finished successfully”. Congrats.
Backup completed. rc 0=good. rc 2=bad
You can use any borg command manually against your repository as needed. For example:
borg list /mnt List your current backups inside the repository borg list /mnt::QNAP-2020-01-26T01:05:36 List all archives inside this specific backup borg info /mnt List general stats of your repository borg check -v –show-rc /mnt Performs an integrity check and returns rc status (0, 1 or 2) 
All that is left is to create the final running script and the cronjob in our QNAP to automate backups. You can skip the next step, as it describes the same process but using SFTP instead of NFS, and head directly to step number Six.

**FIFTH STEP: HTE SAME AS STEP 4, BUT USING SFTP INSTEAD**
If you want to perform backups to an off-site machine, like another NAS located elsewhere, then you can’t use NFS or SMB, as they are not prepared to be used through internet and are not safe. We must use SFTP. SFTP is NOT FTP over SSL (that is FTPS). SFTP stands for Secure File Transfer Protocol, and it’s based on SSH but for file transfer. It is secure, as everything is encrypted, but expect lower speed due encryption overhead. We need to first set it up SSH on our target machine, so be sure to enable it. I also recommend to use a non standard port. In our example, we are using port 4000.
IMPORTANT NOTE: To use SFTP, borg backup must be running in the target machine. You can run it baremetal, or use a container, just as in our QNAP, but if you really can’t get borg running in the target machine, then you cannot use SFTP. There is an alternative, though: SSHFS, which is basically NFS but over SSH. With it you can securely mount a folder over internet. Read this documentation (https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh) and go back to Third Step once you got it working. SSHFS is not covered in this tutorial.
First go to your target machine, and create a new user (in our example this will be “targetuser”)
Second we need to create SSH keys, so both the original machine and the target one can perform SSH connection without needing for a password. It also greatly increases security. In our original container run
ssh-keygen -t rsa 
When you are asked for a passphrase just press enter (no passphrase). Your keys are now stored in ~/.ssh To copy them to your target machine, use this:
ssh-copy-id -p 4000 [email protected] 
If that don’t work, this is an alternative command you can use:
cat ~/.ssh/id_rsa.pub | ssh -p 4000 [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys" 
You will be asked for targetuser password when connecting. If you were successful, you can now SSH without password in the target machine using “ssh -p 4000 [email protected]”. Try it now. If you get to login without password prompt, you got it right. If it still asks you for password when SSH’ing, try repeating the last step or google a little about how to transfer the SSH keys to the target machine.
Now that you are logged in your target machine using SSH, install Borg backup if you didn’t previously, create the backup folder (/backup in our example) and init the repository as was shown in Third Step.
borg init -e repokey –storage-quota 200G /backup 
Once the repository is initiated, you can exit SSH using “exit” command. And you will be back in your container. You know what comes next.
cd /persist touch backup.sh chmod 700 backup.sh nano backup.sh 
Now paste this inside:
#!/bin/sh # Setting this, so the repo does not need to be given on the command line: export BORG_REPO=ssh://[email protected]:4000/backup # Setting this, so you won't be asked for your repository passphrase: export BORG_PASSPHRASE='YOURsecurePASS' # or this to ask an external program to supply the passphrase: # export BORG_PASSCOMMAND='pass show backup' # some helpers and error handling: info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM info "Starting backup" # Backup the most important directories into an archive named after # the machine this script is currently running on: borg create \ --verbose \ --filter AME \ --list \ --stats \ --show-rc \ --compression lz4 \ --exclude-caches \ --exclude '*@Recycle/*' \ --exclude '*@Recently-Snapshot/*' \ --exclude '*[email protected]__thumb/*' \ \ ::'QNAP-{now}' \ /output \ backup_exit=$? info "Pruning repository" # Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly # archives of THIS machine. The 'QNAP-' prefix is very important to # limit prune's operation to this machine's archives and not apply to # other machines' archives also: borg prune \ --list \ --prefix 'QNAP-' \ --show-rc \ --keep-daily 7 \ --keep-weekly 4 \ --keep-monthly 6 \ prune_exit=$? # use highest exit code as global exit code global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit )) if [ ${global_exit} -eq 0 ]; then info "Backup and Prune finished successfully" elif [ ${global_exit} -eq 1 ]; then info "Backup and/or Prune finished with warnings" else info "Backup and/or Prune finished with errors" fi exit ${global_exit} 
CTRL+O to save, and CTRL+X to exit. OK, let’s do it.
./backup.sh 
It should correctly connect and perform your backup. Note that the only thing I modified from the script shown in Fourth Step is the “BORG_REPO” line, which I substituted from local “/mnt” to remote SSH with our target machine and user data.
Finally all that is left is to automate this.

**SIXTH STEP: AUTOMATING BACKUP**
The only problem is that containers can’t retain mount when they reboot. That is not problem if you are using SFTP, but in case of NFS, we need to re-mount each time the container is started, and fstab does not work in container. The easiest solution is create a script called “start.sh”
cd /persist mkdir log touch start.sh chmod 700 start.sh nano start.sh 
and inside just paste this:
#!/bin/bash log=”/persist/log/borg.log” mount -t nfs 192.168.1.200:/backup /mnt /persist/backup.sh 2>> $log echo ==========FINISH========== >> $log 
Save and try it. Stop container, and start it again. If you use “ls /mnt” you will see that the repository is no longer there. That is because the mounting point unmounted when you stopped the container. Now run
/persist/start.sh 
When it’s finished, a log file will appear inside /persist/log. It contains everything borg was previously putting in the screen, and you can check it using
cat /persist/log/borg.cat 
Everything is ready. All we need to do is is create a crontab job to automate this script whenever we want. You can read here how to edit crontab in QNAP (https://wiki.qnap.com/wiki/Add_items_to_crontab). Add this line to the crontab:
0 1 * * * docker start borgbackup && docker exec borgbackup -c /bin/bash “/persist/start.sh” && docker stop borgbackup 
That will launch container each day at 1:00 am, run the start.sh script, and stop the container when finished.

**EXTRA: RECOVERING OUR DATA**
In case you need to recover your data, you can use any device with Borg installed. There are two commands you can use: borg extract and borg mount. Borg extract will extract all files inside an archive into current directory. Borg mount will mount the repository so you can navigate it, and choose specific files you want to recover, much like NFS or SMB work.
Some examples:
borg extract /mnt::QNAP-2020-01-26T01-05-36 -> Extract all files from this specific backup time point into current directory borg mount /mnt::QNAP-2020-01-26T01-05-36 /recover -> Mounts this specific backup time point inside the /recover directory so you can navigate and search files inside borg mount /mnt /recover -> Mounts all backup time points inside the /recover directory. You can navigate inside all time points and recover whatever you want borg umount /recover -> Unmounts the repository from /recover 

I know this is a somewhat complicated tutorial, and sincerely, I don’t think there will be a lot of people interested, as Borg is for advanced users. That said, I had a ton of fun using borg and creating this tutorial. I hope it can help some people. I am conscious that like 99% of this community's users do not need advanced features and would do great using HB3... But TBH, I'm writing for that 1%.
Next up: I’m trying a duplicati container that it is supposed to have GUI, so… maybe the next tutorial will be a GUI based backup tool. How knows?
submitted by Vortax_Wyvern to qnap [link] [comments]

MAME 0.215

MAME 0.215

A wild MAME 0.215 appears! Yes, another month has gone by, and it’s time to check out what’s new. On the arcade side, Taito’s incredibly rare 4-screen top-down racer Super Dead Heat is now playable! Joining its ranks are other rarities, such as the European release of Capcom‘s 19XX: The War Against Destiny, and a bootleg of Jaleco’s P-47 – The Freedom Fighter using a different sound system. We’ve got three newly supported Game & Watch titles: Lion, Manhole, and Spitball Sparky, as well as the crystal screen version of Super Mario Bros. Two new JAKKS Pacific TV games, Capcom 3-in-1 and Disney Princesses, have also been added.
Other improvements include several more protection microcontrollers dumped and emulated, the NCR Decision Mate V working (now including hard disk controllers), graphics fixes for the 68k-based SNK and Alpha Denshi games, and some graphical updates to the Super A'Can driver.
We’ve updated bgfx, adding preliminary Vulkan support. There are some issues we’re aware of, so if you run into issues, check our GitHub issues page to see if it’s already known, and report it if it isn’t. We’ve also improved support for building and running on Linux systems without X11.
You can get the source and Windows binary packages from the download page.

MAMETesters Bugs Fixed

New working machines

New working clones

Machines promoted to working

New machines marked as NOT_WORKING

New clones marked as NOT_WORKING

New working software list additions

Software list items promoted to working

New NOT_WORKING software list additions

Source Changes

submitted by cuavas to emulation [link] [comments]

MAME 0.215

MAME 0.215

A wild MAME 0.215 appears! Yes, another month has gone by, and it’s time to check out what’s new. On the arcade side, Taito’s incredibly rare 4-screen top-down racer Super Dead Heat is now playable! Joining its ranks are other rarities, such as the European release of Capcom‘s 19XX: The War Against Destiny, and a bootleg of Jaleco’s P-47 – The Freedom Fighter using a different sound system. We’ve got three newly supported Game & Watch titles: Lion, Manhole, and Spitball Sparky, as well as the crystal screen version of Super Mario Bros. Two new JAKKS Pacific TV games, Capcom 3-in-1 and Disney Princesses, have also been added.
Other improvements include several more protection microcontrollers dumped and emulated, the NCR Decision Mate V working (now including hard disk controllers), graphics fixes for the 68k-based SNK and Alpha Denshi games, and some graphical updates to the Super A'Can driver.
We’ve updated bgfx, adding preliminary Vulkan support. There are some issues we’re aware of, so if you run into issues, check our GitHub issues page to see if it’s already known, and report it if it isn’t. We’ve also improved support for building and running on Linux systems without X11.
You can get the source and Windows binary packages from the download page.

MAMETesters Bugs Fixed

New working machines

New working clones

Machines promoted to working

New machines marked as NOT_WORKING

New clones marked as NOT_WORKING

New working software list additions

Software list items promoted to working

New NOT_WORKING software list additions

Source Changes

submitted by cuavas to MAME [link] [comments]

MAME 0.215

MAME 0.215

A wild MAME 0.215 appears! Yes, another month has gone by, and it’s time to check out what’s new. On the arcade side, Taito’s incredibly rare 4-screen top-down racer Super Dead Heat is now playable! Joining its ranks are other rarities, such as the European release of Capcom‘s 19XX: The War Against Destiny, and a bootleg of Jaleco’s P-47 – The Freedom Fighter using a different sound system. We’ve got three newly supported Game & Watch titles: Lion, Manhole, and Spitball Sparky, as well as the crystal screen version of Super Mario Bros. Two new JAKKS Pacific TV games, Capcom 3-in-1 and Disney Princesses, have also been added.
Other improvements include several more protection microcontrollers dumped and emulated, the NCR Decision Mate V working (now including hard disk controllers), graphics fixes for the 68k-based SNK and Alpha Denshi games, and some graphical updates to the Super A'Can driver.
We’ve updated bgfx, adding preliminary Vulkan support. There are some issues we’re aware of, so if you run into issues, check our GitHub issues page to see if it’s already known, and report it if it isn’t. We’ve also improved support for building and running on Linux systems without X11.
You can get the source and Windows binary packages from the download page.

MAMETesters Bugs Fixed

New working machines

New working clones

Machines promoted to working

New machines marked as NOT_WORKING

New clones marked as NOT_WORKING

New working software list additions

Software list items promoted to working

New NOT_WORKING software list additions

Source Changes

submitted by cuavas to cade [link] [comments]

Format String Vulnerability How to print out a number in binary format using C/C++ ... Unary Operators in C Programming Language How to print in binary Tree Traversal Spiral Order C Programming Tutorial - 2 - Setting Up Code Blocks - YouTube printf() & Format Specifiers in C Programming Language Use of Format Codes within printf() function C Programming - printf(precision, width and flags) 3. Printf Scanf and Format Specifier in C C Programming Tutorial  Integer Format Specifier & Variable in Printf  Chap-2  Part-9

By default, C provides a great deal of power for formatting output. The standard display function, printf, takes a "format string" that allows you to specify lots of information about how a program is formatted. Note: if you are looking for information on formatting output in C++, take a look at formatting C++ output using iomanip. C Printf Format Codes Binary Options October 06, 2017 Get link; Facebook; Twitter; Pinterest; Email; Other Apps Is there a printf converter to print in binary format? The printf() family is only able to print in base 8, 10, and 16 using the standard specifiers directly. I suggest creating a function that converts the number to a string per code's particular needs. Tuesday, 11 July 2017. C Printf Format Codes Binary Options In this C programming language tutorial we take another look at the printf function. We will look at how to use format specifiers to print formatted output onto the screen. The topics covered are; a little printf background, format specifiers and conversions, formatting of different types and format conversions of strings. printf Background Printf format codes binary options November 18, 2017 The C printf-style format codes specify how data should be transferred using a format ... Finally, the flags and the width padding options described in Syntax are also available when using printf-style format codes. Printf-Style. Description %% Insert a single % character. %b, %B %wb, %wB %w.mb, %w.mB. Transfer data in binary notation, w is the total width, m is the minimum number of non-blank ... Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here. A great thing about the printf formatting syntax is that the format specifiers you can use are very similar — if not identical — between different languages, including C, C++, Java, Perl, PHP, Ruby, Scala, and others. How to Format with printf() in C Programming. By Dan Gookin . The most popular output function in C programming has to be printf(). It’s everyone’s favorite. It’s one of the first functions you learn in C. And as one of the most complex, it’s one of the functions that no one ever fully knows. The power in printf() lies in its formatting string. That text can be packed with plain text ... additional arguments − Depending on the format string, the function may expect a sequence of additional arguments, each containing one value to be inserted instead of each %-tag specified in the format parameter (if any). There should be the same number of these arguments as the number of %-tags that expect a value. Return Value. If successful, the total number of characters written is returned.

[index] [26224] [1957] [1479] [27886] [28837] [9752] [4618] [17067] [14399] [15074]

Format String Vulnerability

This video is unavailable. Watch Queue Queue. Watch Queue Queue Website - https://thenewboston.com/ GitHub - https://github.com/thenewboston-developers Reddit - https://www.reddit.com/r/thenewboston/ Twitter - https://twi... In this video, I have explained you about the unary operators in C Programming language. The Unary Operators includes: Post Increment / Decrement Operators P... Printf function in C Language, Santhosh C Classes, Santhosh Voruganti C Classes, C telugu, Easy to Learn C, C Language Tutorials in Telugu, Scanf Function in C, Format Specifier in C, Vulnerability in the C library printf() function and how to take advantage of it. InCTFj is a Capture The Flag contest exclusive for school students in India. REGISTER NOW : https://junior.inctf ... This feature is not available right now. Please try again later. For the Love of Physics - Walter Lewin - May 16, 2011 - Duration: 1:01:26. Lectures by Walter Lewin. They will make you ♥ Physics. Recommended for you This video will the first introduction for the format specifiers, as we shall expand the concept in this chapter and understand how to print values from vari... Printing in binary format using the printf function is not as easy as it is with other bases (decimal, hexadecimal or octal) but can be done relatively easy with this algorithm. Check out our ... In this video, I will show you how to convert an integer number to binary format string and display it using C/C++ NOTE: This approach assumes positive numbe...

http://binaryoptiontrade.recrifootge.tk