Git Product home page Git Product logo

Comments (9)

Serasidis avatar Serasidis commented on August 24, 2024

Sorry but Github is a new tool for me. I am still learning how it works.
Could you please help me on this "white space" issue ?

from arduino_stm32.

RickKimball avatar RickKimball commented on August 24, 2024

Different code editors use different methods to indent. Some use spaces, some use tabs and some use custom tab widths. If we all use different tab widths and spacing for indenting then the code looks very strange when people make changes.

If we document how white space (\r\n, \n, \b , \t ) are used then it will be easier to have code that looks the same for everyone.

The Arduino IDE uses 2 for the tab width. However, typically people writing the libraries don't. I don't even know what this code is supposed to be. That is why I'm asking. [Edit] I just looked and the Arduino 1.6.5 * what i'm using * inserts spaces even if i use tabs.[/edit]

from arduino_stm32.

Serasidis avatar Serasidis commented on August 24, 2024

I use Notepad++ as it is my favorite text editor.
I setup the Notepad to use 2 white spaces for every depth change (for {...})
Moreover, I choose to convert any Tab into 2 white spaces.

alt tag

from arduino_stm32.

RickKimball avatar RickKimball commented on August 24, 2024

Most of the maple code I've looked at is setup with tabs set to 4 or the code is using 4 spaces.

[Edit] I just looked and it seems like most of it is 4 spaces no tabs [/Edit]

from arduino_stm32.

rogerclarkmelbourne avatar rogerclarkmelbourne commented on August 24, 2024

Vasillis

I use Notepad++ as well.

I noticed that lots of code has different spacings, but as AFIK, white space doesn't effect the function of a C program. I'm not sure how this is technical issue. (unlike some other languages)

Please correct me if I'm wrong

from arduino_stm32.

RickKimball avatar RickKimball commented on August 24, 2024

It isn't a technical issue. .. I guess it is fine.

from arduino_stm32.

RickKimball avatar RickKimball commented on August 24, 2024

I guess anything goes.

from arduino_stm32.

victorpv avatar victorpv commented on August 24, 2024

I'm thinking this kind of stuff should have a section in the forums called:
"Coding standards"
Some guidelines, if you don't follow them nothing breaks, if you follow them is easier to read, so I think is a subject for the forum.

from arduino_stm32.

rogerclarkmelbourne avatar rogerclarkmelbourne commented on August 24, 2024

This is loosely coding standards, but wasn't rick's issue that the file has strange tab settings.
I suspect that the tab settings may not even have been defined by Vasillis, but as the library was ported I suspect that the tab settings may well have come from the original author of the library.

Its asking a bit much of anyone porting a library, that they reformat all the code.

In terms of coding standards, I'd be more inclined to be concerned about things like this

  while (len)
  {
    uint16_t addr = pgm_read_word(buf++); len--;
    uint16_t n = pgm_read_word(buf++); len--;

Which appear to be in the original library

https://github.com/maniacbug/VS1053/blob/master/VS1053.cpp

(a) Why are addr and n both defined inside a while loop ???
(b) Why is len--; not on its own line ?
(c) Why is len being decremented twice when the second line doesn't use len e.g.

    uint16_t n = pgm_read_word(buf++); 

doesn't use len, do why bother decrementing it after setting up addr

However I think our time is better spent fixing issues and porting other libraries etc, rather than nit picking though existing libraries that work OK.

After all, the whole Arduino and Open Source ethos is that anyone can write a library and publish it.

If code formatting is really such an issue, please feel to run lint on the code, however also please be sure to test your reformatted code on the hardware it supports, just on the offchance that somehow the reformatting went wrong.

from arduino_stm32.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.