bugGNU indent - Bugs: bug #65165, extern "C" mishandled in...

 
 

bug #65165: extern "C" mishandled in header files

Submitter:  Mike Frysinger <vapier>
Submitted:  Mon 15 Jan 2024 02:15:44 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 11 Mar 2024 10:39:22 AM UTC, comment #1: 

I see that a patch was submitted for this in 2007, but it lacked documentation:

https://lists.gnu.org/archive/html/bug-indent/2007-08/msg00007.html

I see that the patch does not cleanly apply to the latest code in the repository, but is the approach sound?

Should it be used as a starting point?

Eric Herman <eric_herman>
Mon 15 Jan 2024 02:15:44 AM UTC, original submission:  

example file:


$ cat test.h
#if defined __cplusplus
extern "C" {
#endif

extern int foo (void);

#if defined __cplusplus
}
#endif


formatting it makes it think the extern marking is a scope and reindents incorrectly.  not sure if the { should stay with the extern line either.


$ indent -st test.h
#if defined __cplusplus
extern "C"
{
#endif

  extern int foo (void);

#if defined __cplusplus
}
#endif


and for clarity, here's the diff:


@@ -1,8 +1,9 @@
 #if defined __cplusplus
-extern "C" {
+extern "C"
+{
 #endif

-extern int foo (void);
+  extern int foo (void);

 #if defined __cplusplus
 }


Mike Frysinger <vapier>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by eric_herman (Posted a comment)
  • -email is unavailable- added by vapier (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code