Is there any way to get the absolute path of functions in map files? Map files support following format
0001:000016a0 func 00000001400026a0 f lib:func.o
Is there any way to get the absolute path of "func"
This may not be useful depending on your situation, but some linkers do not support having multiple object files with the same name in different directories. So if you give them some_directory/func.o and some_other_directory/func.o, only one of them will be linked. I know CodeWarrior does this.
In order to avoid this problem, I make sure that all of my object files have unique names. The convention I use is to include an abbreviation of the module name, for example, func_module.o. With that convention it is easy to identify the object file. Or if you need to do so programatically, any file searching technique will suffice.
Some versions of Visual Studio put all object files into a single directory, regardless of the organization of the .c and/or .cpp files, and will automatically append numeric suffixes to avoid conflicts. Figuring out which object file goes to which .c file requires reading the project file.
Related
I've found this question which is basically asking the same, but got no real answer.
Where is the make's config file / database file where it remembers the file timestamps, so it can tell what changed? I checked and there's no .make or similar in my project, nor in the home directory.
Or does it somehow store the information inside the files themselves, perhaps by modifying the timestamps? (That sounds fishy though)
There is no such "database". The program simply compare the filesystems modification and creation timestamps of source and target files.
Lets say you have the following rule:
some_target: some_source_1 some_source_2
Then if the modified timestamp of either some_source_1 or some_source_2 is later than the modification/creation time of some_target then the rule will activate and the target will be rebuilt.
Makefiles describe targets and dependencies. Make executes commands to create/recreate the target(s) if necessary.
If the target doesn't exist, then make will try to create it.
If the target does exist, make compares the modification times of the target and its dependencies. If any of the dependencies was modified after the target was modified, then make will execute the command(s) to regenerate the target.
For example, for C files the target is the corresponding .o file and the dependency is on the file containing the C source code (and possibly some include files). If the .c file is newer than the .o file, then make runs the C compiler. This will generate a .o file with a newer modification time than the .c file.
I want to know how to do something like the following...
I have a directory, let's call this directory "D:\Folder\" and it has some file types like .json, .lua, etc and I need to be able to put the appropriate files in a table based off their file type. How do I do this via Lua without external libraries? Also, how can I get other information on the files, like size, date modified, etc via lua and store that info?
As Yu Hao said in the comment, Lua by itself doesn't have any methods to get the list of files in a folder or access attributes of those files. In terms of external libraries, you can use Lua Filesystem module that has everything you need or winapi if you are looking for Windows-specific solution. Both are small libraries that can be compiled quite easily using mingw.
If you are looking for Windows-only-no-external-library solution, you should be able to run "dir" command and process its results using io.popen. You can parse the captured output and get file names, sizes, and dates based on that. You can also get the file size by using file:seek, but since you may be parsing anyway, you can get it all from the output. I don't think there is anything much simpler than that.
how about searching for a pattern that represents any and all characters a file could posses and then .file_type...and then run that through io.open for example...possible?
You won't be able to "guess" filenames by enumerating possible symbol combinations simply because this .... will .... take .... a .... very .... long .... time.
I have three .asn files. After these three files are compiled by the asn.1 compiler, each file has a corresponding directory in the output folder. In each folder, there are many C source files that were generated by the asn.1 compiler. There is always a .c file which has the same name as the .asn file (except the extension name, i.e. test.asn and test.c). In this file, some functions are defined; like asn_alloc, asn_free etc.
So, there are three files implementing the asn_alloc and asn_free functions. I'll use all the generated C files in my C project.
The problem is, the asn_alloc function is defined in three places. This is the reason I'm getting the compiler error:
multiple definition of function
How do I deal with this problem? I think that editing the generated source file is not a good idea.
This problem is specific to the ASN.1 Tool you are using. With some ASN.1 Tools (such as the one at http://www.oss.com), you can either include all of the .asn files in the same compilation so that one .c file is generated with all names disambiguated, or you can use the -prefix xxx option on each compilation where xxx is different for each ASN.1 compilation thus causing the generated names to be prefixed with xxx, therefore not conflicting.
which environmental variable indicates the list of all the directories which are searched in order to find out the header file included in a C file in the Linux kernel? I have some header files in a directory, and would like to include the path to that directory in the list of all directories searched. How may I do that? I tried exporting C_INCLUDE_PATH, but that doesn't remove the error, which says that it still can't find the header file.
Thanks,
D.
There is generally no environment variable that lists all of the directories searched for header files. The directories searched are a function of the compiler used. Your compiler almost certainly has a command-line switch to add a directory to the search list. E.g., for GCC and clang, consider the ā-Iā switch and related switches. Your compiler may also have environment variables where you can list directories to be added to the search list, such as C_INCLUDE_PATH. Keep in mind these likely list additional directories to search; they do not list all the directories searched.
Add -I/where/ever arguments to EXTRA_CFLAGS in your Makefile. Though generally this kind of thing is bad form. The kernel build includes its own include tree (and the local directory, of course). Is there a reason your code can't conform to the existing framework?
I have around 120 header files (.h files) , and in all of them each one includes many other header files using #include <abcd/xyz.h>, but as I kept .h files in a specific folder, preprocessor is generating filenotfound error.
I moved all the .h files to the single .C file that is calling the first headerfile.
One way to do is make #include <abcd/xyz.h> as #include "abcd/xyz" , but I need to do this in all the header files wherever there is an include statement, and there are hundreds of them.
I can't include many of them in the headerfiles section in Visualstudio because, some of the headerfiles have the same name, but they reside in different directories. (<abcd/xyz.h>,<efgh/xyz.h>).
Any way to do this?
You should add a path into "Additional include directories" in the "C++" section of the project options (the "General" tab). You can use environment variables as well as "this folder" (.) shortcut and "up one folder" (..) shortcut for this setting to not be bound to a certain directory structure.
and I can't include many of them in the headerfiles section in Visualstudio because , some of the headerfiles have the same name, but they reside in different directories.(,)
That's a pretty big problem unless the files that are including those non-uniquely named headers are in the same directory as the header files themselves.
You have no way to guarantee that the compiler will locate one header before another without modifying the #include directive itself (and adding a relative path as one example).
EDIT: It looks like Visual Studio will allow you to specify different Additional Include Directories for each source file in a project (rt-click on the source file in Solution Explorer and modify C/C++ properties). But I think this would be more work than modifying the #include directives themselves - depends on how many non-unique header filenames you have.
In the project settings (under C/C++ in VS2005/2008) there's an option for "additional include directories". You can add the folders containing your header files here, using relative paths.
You can also do this at the IDE level in Tools -> Options -> Projects and Solutions -> VC++ Directories -> Include Files. Typically this method is reserved for headers included as part of a formal library. The first option is typically preferred as it's portable (you can ship your project file to another developer and, provided you use relative/macro'd paths, they can build the project as-is).
What you're looking for is the -I flag and you give the directory...
If you have a Makefile, you should add it to the CPP_FLAGS something like that....
You can also add an INCLUDE variable to your environment variables.