Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » C++ preprocessor #if Indents(C++ preprocessor #if Indents)
C++ preprocessor #if Indents [message #1720490] Mon, 18 January 2016 17:35 Go to next message
Eclipse UserFriend
is there a way to make the auto styling feature of eclipse C/C++ IDE format preprocesors if statements like:
#ifdef ARDUINO
  #if ARDUINO < 100
    #include "WProgram.h"
  #else
    #include "Arduino.h"
  #endif

  #if defined(CORE_TEENSY) && defined(__MK20DX256__)
    #include <i2c_t3.h>
    #define BUFFER_LENGTH 32
  #elif I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include <Wire.h>
  #endif
  #if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
    #include <I2C.h>
  #endif
#endif


instead of :
#ifdef ARDUINO
#if ARDUINO < 100
#include "WProgram.h"
#else
#include "Arduino.h"
#endif
#if defined(CORE_TEENSY) && defined(__MK20DX256__)
#include <i2c_t3.h>
#define BUFFER_LENGTH 32
#elif I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include <Wire.h>
#endif
#if I2CDEV_IMPLEMENTATION == I2CDEV_I2CMASTER_LIBRARY
#include <I2C.h>
#endif
#endif
Re: C++ preprocessor #if Indents [message #1720605 is a reply to message #1720490] Tue, 19 January 2016 12:07 Go to previous messageGo to next message
Eclipse UserFriend
Technically, the preprocessor stuff is another language. There doesn't seem to be a way to address indentation of processor statements in the formatter editing dialogs. You should submit an enhancement request. If you can't wait, either write an external code formatter (tun outside of Eclipse) or modify the CDT code.

You also might want to ponder this discussion: http://stackoverflow.com/questions/2975330/how-do-you-indent-preprocessor-statements
Re: C++ preprocessor #if Indents [message #1720617 is a reply to message #1720605] Tue, 19 January 2016 15:22 Go to previous messageGo to next message
Eclipse UserFriend
in a world where style is controlled and the code is adjusted to match it would be nice to enable the style to indent #if statements like if statements.

while #if might technically be a different language it is part of the C/C++ environment and as it is not a letter for letter match of any C/C++ current key words there is no reason that #if's can not be accommodated for in the styling.

if i knew where to modify the CDT code i would do just that.

Re: C++ preprocessor #if Indents [message #1720622 is a reply to message #1720617] Tue, 19 January 2016 17:02 Go to previous message
Eclipse UserFriend
You could download the CDT source. Likely, the formatter is part of it.
This what someone did for Java: http://www.peterfriese.de/formatting-your-code-using-the-eclipse-code-formatter/

You could configure an external tool which might be simpler. Here's how to use one in Eclipse:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-exttools-running.htm
Previous Topic:Yocto ADT plugin - No rule to make target all error
Next Topic:Problem with program (Multiplication up to 100)
Goto Forum:
  


Current Time: Sat Aug 09 22:59:29 EDT 2025

Powered by FUDForum. Page generated in 0.04845 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top