Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Organize includes incorrect function forward declaration(CDT organize includes not working properly)
Organize includes incorrect function forward declaration [message #1766264] Mon, 19 June 2017 15:31 Go to next message
Pranav Pareek is currently offline Pranav PareekFriend
Messages: 2
Registered: May 2017
Junior Member
I have a very simple c program as below. When I run organize includes on the code it removes all the unwanted include files and forward declares functions. But sometimes this declaration is not correct. For example in the case of printf(), it accepts variable arguments but cdt forward declare the function with only one argument which is incorrect. I think the organize include feature is not working properly, can anyone help me to make it work correctly.

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    int a;
    char src[50], dest[50];
    strcpy(src, "This is test");
    strcpy(dest, "This is test2");
    strcat(src, dest);
    puts("!!!Hello World!!!");
    a = 5;
    printf("%d\n", a);
    return 0;
}


and i get the following output after running organize includes:
int printf(const char *); // <------ wrong forward declaration?
int puts(const char *);
char * strcat(char *, const char *);
char * strcpy(char *, const char *);

int main(void) {
    int a;
    char src[50], dest[50];
    strcpy(src, "This is test");
    strcpy(dest, "This is test2");
    strcat(src, dest);
    puts("!!!Hello World!!!");
    a = 5;
    printf("%d\n", a);
    return 0;
}
Re: Organize includes incorrect function forward declaration [message #1766323 is a reply to message #1766264] Tue, 20 June 2017 08:41 Go to previous message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
I have created https://bugs.eclipse.org/bugs/show_bug.cgi?id=518491 for this issue.

Contributions more than welcome. I have already created a minimal junit test case so it should be easy to get started.

https://wiki.eclipse.org/CDT/contributing

In the meantime, I don't have a solution. As far as I can tell this looks to affect varargs mostly, and if you do the fixup manually once future Organize Includes does not break the code.
Previous Topic:make error 1 without any description
Next Topic:Change application transfer protocol (remote debugging)
Goto Forum:
  


Current Time: Tue Sep 24 15:56:36 GMT 2024

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

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

Back to the top