I need to write a code to identify if a contact id is associated with an administrator role in my civiCRM extension and it needs to be platform independent. How can I achieve it ?
I don't think you can do this in a platform-independent way since "admin role" means different things in different CMS's. What you can do that is platform-independent is check specific CiviCRM permissions, e.g.
CRM_Core_Permission::check('administer CiviCRM', $contact_id)
You can leave out $contact_id to check for the currently logged-in user.